.netxamarinxamarin.ios.net-standardtypeloadexception

Using .NET Standard in Xamarin iOS


I have added a reference to a .NET Standard Library (1.3) in my Xamarin iOS project.

In runtime, when I create an instance of a class defined in the .NET Standard Library, it throws this exception:

Unhandled Exception:

System.TypeLoadException: Could not find method due to a type load error

For example, it happens when I do:

var c = new Customer();

What's happening and how can I fix it?


Solution

  • Finally I did it: The problem was that I had to include transitive references. That is, my project A references B, and B references C. So I had to include A => C. Not pretty obvious. I also had to include all the NuGet packages my references use. Building and running now!