如何在xamarin iOS中使用netstandard libs?

时间:2017-02-27 00:58:45

标签: c# ios xamarin .net-standard

每次我添加对netstandard only库的引用时,都会出现以下错误。专门针对xamarinios10的Libs工作正常。

  

错误CS0012:类型System.Object' is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Runtime,Version = 4.0.20.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'

例如,将AutoMapper库添加到新鲜的" iOS库"项目不起作用。它也不适用于我自己的任何针对netstandard的NuGet包。

1 个答案:

答案 0 :(得分:3)

要使.NET Standard包与Xamarin iOS一起使用,您需要手动将对System.Runtime的引用添加到* .csproj文件中。此参考在Xamarin Studio中突出显示为无效,但项目编译并在设备和模拟器中工作。例如,为了使最简单的应用程序工作,我最终在我的csproj

中有这个
<ItemGroup>
  <Reference Include="System" />
  <Reference Include="System.Xml" />
  <Reference Include="System.Core" />
  <Reference Include="Xamarin.iOS" />
  <Reference Include="System.Runtime" />
</ItemGroup>

注意底部的System.Runtime引用。

相关问题