6

我在OS X上的Xamarin Studio中使用了可移植类库(PCL)。我有两个PCL库,面向.NET 4.5,Windows Phone 8,Windows Store应用程序,Xamarin.iOS,和Xamarin.Android。我在iOS,Android和单元测试项目中引用这两个库。在3个领域我收到以下错误:便携式类库System.Object错误

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'.

的代码很简单:

MyClass myClass = new MyClass(); 

错误在每个引用该PCLS项目的一次发生。他们都不是同一班。我是PCL新手。我尝试删除Windows Phone 8(因为我最后一分钟添加了它),但问题没有消失。任何帮助将被解雇!

谢谢!

更新:

因此,这与发生在类(其中类是从PCL项目)宣布第一场。

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

另一个奇数的方面是,有使用这些类超过50类,并且误差只出现在三个等级。

+0

这是简介78,对吗? –

+0

是的,它是个人资料78. – JamWils

回答

5

我刚刚遇到了这个完全相同的问题,并且具有与您相同的设置。在评论中提到的小费(由Stuart提供,后者又提到了@DavKean的推文)至this问题为我解决了。

你必须:

  • 访问Windows机器上(我用的是Windows 8中)
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
  • 将它复制到你的Mac
  • 从每到这个dll参考你的iOS和Droid项目
+0

这确实解决了错误。但是,这绝对不是应该如何解决的。这引发了一个问题。 Mono(Xamarin)使用的System.Runtime.dll是否有自己的实现?我为此提出了一个错误,如果有人好奇,这里是链接。谢谢您的帮助。 https://bugzilla.xamarin.com/show_bug.cgi?id=13400 – JamWils

+0

我有相同的问题 - 但使用VS的Monotouch。当添加System.Runtime.dll时,不会再抛出错误 - 但是在编译错误时仍然会抛出控制台。 你有没有在Windows上试过这个? – LewisBenge

1

您正在使用哪个版本的Xamarin.Android和Xamarin.iOS?您需要使用Xamarin.Android 4.7.x alpha版支持PCL,或即将发布的4.8版。 (同上Xamarin.iOS:你需要一个等待未来发布的PCL支持,或者使用Alpha通道。)

+0

我刚刚在beta频道上昨天(2013年7月20日)升级到Xamarin.Android 4.8和Xamarin.iOS 6.3.8。我的印象是PCL在这个版本中得到了支持。我需要切换到Alpha通道吗? – JamWils

+0

AFAIK,PCL支持目前仅在Alpha频道提供 –

+0

@jonp我仍然遇到alpha通道上的这个问题 –