我在 OS X 上的 Xamarin Studio 中使用可移植类库 (PCL)。我有两个面向 .NET 4.5、Windows Phone 8、Windows Store Apps、Xamarin.iOS 和 Xamarin.Android 的 PCL 库。我在我的 iOS、Android 和单元测试项目中引用了这两个库。在 3 个方面,我收到以下错误:
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();
该错误在每个引用 PCL 的项目中都会发生一次。他们都不是同一个类(class)。我是 PCL 的新手。我已经尝试删除 Windows Phone 8(因为我在最后一分钟添加了它),但问题并没有消失。任何帮助都会受到欢迎!
谢谢!
更新:
所以这发生在类中声明的第一个字段(该类来自 PCL 项目)。
int a = 0;
MyPCLClass _myPCLClass = new MyPCLClass(); //This is where the error appears
另一个奇怪的方面是使用这些类的类有 50 多个,并且错误仅出现在三个类中。
最佳答案
我刚刚遇到了这个完全相同的问题,并且设置与您相同。评论中提到的提示(由 Stuart 提供,后者又提到了@DavKean 的推文)给 this问题为我解决了。
你必须:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
dll
的引用来自您的每个 iOS 和 Droid 项目 关于xamarin.ios - 可移植类库 System.Object 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17766014/