如何在Xamarin iOS中使用Netstandard库?

编程入门 行业动态 更新时间:2024-10-24 06:33:26
本文介绍了如何在Xamarin iOS中使用Netstandard库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次我添加仅对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库?

本文发布于:2023-11-14 15:25:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587824.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Xamarin   Netstandard   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!