通過Xamarin大學課程XAM120工作。在我的UWP項目中添加我的IDial
實現時遇到了阻止程序。出於某種原因,我的項目沒有在我的系統上獲取PhoneCallManager
API。
錯誤:
Error CS1069
The type name 'PhoneCallManager' could not be found in the namespace 'Windows.ApplicationModel.Calls'. This type has been forwarded to assembly 'Windows.Foundation.UniversalApiContract, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime' Consider adding a reference to that assembly.
代碼:
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
using Phoneword.UWP;
using Xamarin.Forms;
namespace Phoneword.UWP
{
public class PhoneDialer : IDialer
{
public Task<bool> DialAsync(string phoneNumber)
{
if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsPhoneContract", 1, 0))
{
Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(phoneNumber, "Phoneword");
return Task.FromResult(true);
}
return Task.FromResult(false);
}
}
}
'使用Xamarin.Forms; using System.Threading.Tasks;使用Windows.Foundation.Metadata的 ; using Phoneword.UWP; [assembly:Xamarin.Forms.Dependency(typeof(PhoneDialer))]'這裏是我使用的列表和程序集引用,不幸的是我仍然看到同樣的錯誤。 –
您可以在問題中調整示例代碼以反映您在項目中的含義嗎?因爲如果它是正確的,它會給出更好的概述。 – Depechie