Xamarin Forms Dependency Service 定义问题

Ant*_*tto 2 c# xamarin xamarin.forms uwp

我正在使用 Xamarin 开发和应用程序,我正在尝试遵循本指南,以便为 UWP 的 Xamarin Forms 实现和接口。

所以我用PCL写了这个界面:

namespace MyApp {
public interface ISimplePdfLoader {

    void OpenLocal(string uri);

    void Load(object pdfDoc);
  }
}
Run Code Online (Sandbox Code Playgroud)

在 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) {
        ...
        }
    }
}
}
Run Code Online (Sandbox Code Playgroud)

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

编辑:错误显示在该行的下方[assembly: Dependency(typeof(SimplePdfLoader))]

小智 10

从顶部使用部分删除以下行

using System.Runtime.CompilerServices;
Run Code Online (Sandbox Code Playgroud)

并添加以下内容

using Xamarin.Forms;
Run Code Online (Sandbox Code Playgroud)