Portable Class Library assembly reference problems

2019-04-07 22:38发布

问题:

I have problem in my project where I have PCL for .Net 4.5, Windows Phone 8, WinRT, MonoTouch and MonoDroid, when I try to build MonoDroid or MonoTouch project that have reference to that PCL errors are following:

*Error 1 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'.

Error 2 The type 'System.Enum' 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'.

I have done suggested command (sn -Vr *,b03f5f7f11d50a3a), but it didn't help. I am using the following profile:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78

回答1:

If you set the compability to from .NET 4.5 to .NET 4.0.3 it will work.



回答2:

When I've encountered similar errors in profile 104, then I've built fake System assemblies like System.Windows.dll and System.Net.dll which type forward the classes in question. I've delay signed these fake assemblies - fortunately MonoDroid and MonoTouch don't seem to check these delay signings too carefully.

The examples of these are at: https://github.com/slodge/MvvmCross/tree/v3/PortableSupport

I would guess you could do the same thing with 2 System.Runtime assemblies linked against MonoDroid and MonoTouch and type-forwarding System.Object and System.Enum.

Hopefully Xamarin's PCL support will ship soon - and will include official version for these shim assemblies.