c# - Xamarin Forms UWP 丢失电话调用管理器程序集

标签 c# xamarin xamarin.forms window xamarin.uwp

问题

学习 Xamarin 大学类(class) XAM120 。在将我的 IDial 实现添加到我的 UWP 项目时遇到了阻碍。由于某种原因,我的项目没有在我的系统上获取 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);
        }
    }
}

最佳答案

将以下引用添加到您的 UWP 项目:

enter image description here

关于c# - Xamarin Forms UWP 丢失电话调用管理器程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45157576/

相关文章:

c# - 将一项测试应用于两个不同的类(class)

c# - 即使 DropDownList 已禁用其 View ,SelectedValue 仍应返回一个值

android - Xamarin Android 运行时异常

c# - Xamarin 表格 : Check if user inactive after some time log out app

c# - Xamarin.Forms Picker ItemsSource在XAML中保持为空

xamarin.ios - 在 Xamarin 表单中的所有页面上共享相同的页面标题

c# - 未捕获异步异常

c# - 这是使用 Xamarin Forms 和 SQLite 建立数据库连接的完美方式吗?

c# - 在使用 XAMLC 时,在 FontSize 中使用静态标记扩展会导致无效转换

c# - 为什么在通用参数约束中强制执行某些顺序?