草庐IT

DependencyService

全部标签

android - Xamarin.Forms DependencyService 难以获取位置

因此,在我终于了解Xamarin.FormsDependencyService之后,我几乎得到它返回设备的当前位置。我的界面publicinterfaceICurrentLocation{MyLocationSetCurrentLocation();}我的位置publicclassMyLocation{publicdoubleLatitude{get;set;}publicdoubleLongitude{get;set;}}调用它的行MyLocationlocation=DependencyService.Get().SetCurrentLocation();并且在实现Xamarin.

c# - Xamarin DependencyService : System. MissingMethodException:找不到 [Interface] 的默认构造函数

我在Xamarin.FormsPCL上使用依赖服务时收到此错误。我已经看到此错误的答案涉及iOS和Linker。但是,我在Android上运行它并且Linker已关闭。Debug模式也是如此。它告诉我它在PCL中找不到接口(interface)的默认构造函数。我认为这可能是我所做的一些重命名的问题(我使用了重构工具并确保进行了所有必要的更改)所以我删除了这些文件夹/文件并重新制作了它们。仍然没有:(我已经搜索和调试了好几个小时。可能导致此错误的原因有哪些?我很确定我的DependencyService实现是正确的,所以我觉得它有些不同。这是我的相关代码。接口(interface):na