我试图按照this guide来实现和连接Xamarin Forms for UWP .
所以我在PCL中写了这个界面:
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) {
...
}
}
}
}
但它继续显示 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我无法编译项目 .
edit: 该错误显示在该行的基础 [assembly: Dependency(typeof(SimplePdfLoader))]
2 回答
将
[assembly: Dependency(typeof(SimplePdfLoader))]
更改为[assembly: Xamarin.Forms.Dependency()]
. 你能看到你可以为该Dependency对象提供哪些参数吗?我想应该是这个[assembly: Xamarin.Forms.Dependency(typeof(SimplePdfLoader))]
从顶部使用部分删除下面的行
并添加以下内容