问题描述
每次我添加仅对netstandard库的引用时,都会出现以下错误.专门针对xamarinios10的库效果很好.
Every time I add a reference to netstandard only library I get following error. Libs that specifically target xamarinios10 works just fine.
例如,将AutoMapper库添加到新的"iOS Library"项目中将不起作用.它也不适用于我自己的任何以netstandard为目标的NuGet软件包.
For example adding AutoMapper library to fresh "iOS Library" project does not work. It also does not work for any of my own NuGet packages targeting netstandard.
推荐答案
要使.NET Standard程序包与Xamarin iOS一起使用,您需要手动将对System.Runtime的引用添加到* .csproj文件中.此参考在Xamarin Studio中突出显示为无效,但项目可以在设备和模拟器中编译并运行.例如,为了使最简单的应用程序工作正常,我最终将其保存在csproj
To make .NET Standard package work with Xamarin iOS you need to manually add reference to System.Runtime to your *.csproj file. This reference is highlighted in Xamarin Studio as invalid but project compiles and works on device and in simulator. For example to make simplest possible app work I end up having this in my csproj
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
<Reference Include="System.Runtime" />
</ItemGroup>
请注意底部的System.Runtime引用.
Note System.Runtime references at the bottom.
这篇关于如何在Xamarin iOS中使用Netstandard库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!