我正在使用 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/