2
votes

Every time I add a reference to netstandard only library I get following error. Libs that specifically target xamarinios10 works just fine.

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'

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.

1
I think Xamarin supports netstandard because of this blog post - blog.xamarin.com/net-standard-library-support-for-xamarin and this one - developer.xamarin.com/guides/cross-platform/… - averbin
You will have to use latest Xamarin and VS2017 (better after March 7). - Lex Li
@LexLi I'm tried with Xamarin Studio and Visual Studio Mac Preview none of them works. Are you saying that netstandard in Xamarin only works with Windows and Visual Studio? - averbin
.NET Standard 1.6 support is claimed by Xamarin, and if you could not figure out the way, contact Microsoft/Xamarin suppprt. - Lex Li

1 Answers

4
votes

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>

Note System.Runtime references at the bottom.