c# - Xamarin Forms 依赖服务定义问题

标签 c# xamarin xamarin.forms uwp

我正在使用 Xamarin 开发和应用程序,我正在努力遵循 this guide以便为 UWP 的 Xamarin Forms 实现和接口(interface)。

于是我在PCL中写了这个接口(interface):

namespace MyApp {
public interface ISimplePdfLoader {

    void OpenLocal(string uri);

    void Load(object pdfDoc);
  }
}

我在 MyApp.UWP 中创建了一个类:

[assembly: Dependency(typeof(SimplePdfLoader))]
namespace MyApp.UWP {
public class SimplePdfLoader : ISimplePdfLoader {

    public async void OpenLocal(string uri) {
        ...

        Load(doc);
    }

    public async void Load(object pdfObj) {
        ...
        }
    }
}
}

但它继续显示错误 CS7036 No arguments matching the mandatory formal parameter 'loadHintArgument' of 'DependencyAttribute.DependencyAttribute (string, LoadHint)' were specified MyApp.UWP C:\Users.. .\workspace\my-app\MyApp\MyApp.UWP\SimplePdfLoader.cs 19 而且我无法编译该项目。

编辑:错误显示在 [assembly: Dependency(typeof(SimplePdfLoader))]

行下面

最佳答案

从顶部使用部分删除下面的行

using System.Runtime.CompilerServices;

并添加以下内容

using Xamarin.Forms;

关于c# - Xamarin Forms 依赖服务定义问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53697095/

相关文章:

c# - 无法加载 Xamarin.Forms Visual Studio 2015 中的 memtrack(没有此类文件或目录)错误

c# - Xamarin.Forms:使用披露按钮时删除缩进

c# - 将未知类型的对象传递给函数

c# - LINQ - 左外连接将列表附加到父对象

c# - 具有连接和分组依据的 NHibernate 查询

c# - 对 Xamarin 初学者的初步支持

c# - 如何调试 .NET 运行时中的内部错误?

c# - 可拖动的Boxview崩溃错误Xamarin

ios - xamarin Ios 将 UIView 添加到 ContainerView

xamarin - 未在路径 : DexPathList 上找到类 "com.onesignal.GcmBroadcastReceiver"