每次我添加仅对netstandard库的引用时,都会出现以下错误.专门针对xamarinios10的库效果很好.
Every time I add a reference to netstandard only library I get following error. Libs that specifically target xamarinios10 works just fine.
错误CS0012:类型为System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Runtime,版本= 4.0.20.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'
error CS0012: The type System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assemblySystem.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
例如,将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库?
发布评论