6
votes

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.

2
this is profile 78, right ? - Stephane Delcroix
Yes it is profile 78. - JamWils

2 Answers

5
votes

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:

  • access a Windows machine (I used a Windows 8)
  • grab C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
  • copy it to your Mac
  • add a reference to this dll from each of your iOS and Droid projects
1
votes

Which version of Xamarin.Android and Xamarin.iOS are you using? You need to be using of the Xamarin.Android 4.7.x alphas for PCL support, or the forthcoming 4.8 release. (Ditto for Xamarin.iOS: you need a pending future release for PCL support, or use the alpha channel.)