I am using Portable Class Libraries (PCL) in Xamarin Studio on OS X. I have two PCL libraries that are targeting .NET 4.5, Windows Phone 8, Windows Store Apps, Xamarin.iOS, and Xamarin.Android. I reference these two libraries in my iOS, Android, and Unit tests projects. In 3 areas I am getting the following error:
The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
The code is straightforward:
MyClass myClass = new MyClass();
The error occurs once in each of the projects that reference the PCLs. None of them are the same class. I am new to PCLs. I've tried removing the Windows Phone 8 (as I added it last minute) and yet the problem does not go away. Any help would be appeciated!
Thanks!
Update:
So this occurs with the first field declared in the class (where the class is from the PCL project).
int a = 0;
MyPCLClass _myPCLClass = new MyPCLClass(); //This is where the error appears
Another odd aspect is that there are over 50 classes using these classes, and the error is only appearing in three classes.
I just ran into this exact same problem, and have the same setup as you do. A tip mentioned in a comment (by Stuart, which in turn mentioned a tweet by @DavKean) to this question solved it for me.
You have to:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
dll
from each of your iOS and Droid projectsIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With