Portable System.Object Class Library Error

I use Portable Class Libraries (PCL) in Xamarin Studio on OS X. I have two PCL libraries designed for .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 projects. In 3 areas, I get the following error:

The type "System.Object" is defined in an assembly that is not referenced. You must add a reference to the assembly "System.Runtime, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a".

The code is simple:

MyClass myClass = new MyClass(); 

The error occurs once in each of the projects that reference the PCL. None of them are the same class. I am new to PCL. I tried to uninstall Windows Phone 8 (since I added it at the last minute), but the problem persists. Any help would be called!

Thanks!

Update:

So this happens with the first field declared in the class (where is the class from the PCL project).

 int a = 0; MyPCLClass _myPCLClass = new MyPCLClass(); //This is where the error appears 

Another unusual aspect is that with these classes there are more than 50 classes, and the error appears in only three classes.

+6
source share
2 answers

I ran into the same problem and set the same setting as you. The advice mentioned in the commentary (by Stuart, who in turn mentioned the @DavKean tweet) resolved this issue for me.

You must:

  • Access to a Windows machine (I used 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 link to this dll from each of your iOS and Droid projects.
+5
source

What version of Xamarin.Android and Xamarin.iOS are you using? You need to use alpha Xamarin.Android 4.7.x to support PCL or the upcoming 4.8 release. (The same goes for Xamarin.iOS: you need a future release to support PCL or use the alpha channel.)

+1
source

Source: https://habr.com/ru/post/949905/


All Articles