gpt4 book ai didi

xamarin.ios - 可移植类库 System.Object 错误

转载 作者:行者123 更新时间:2023-12-04 15:00:04 25 4
gpt4 key购买 nike

我在 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问题为我解决了。

你必须:

  • 访问 Windows 机器(我使用的是 Windows 8)
  • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\System.Runtime.dll
  • 将其复制到您的 Mac
  • 添加对此 dll 的引用来自您的每个 iOS 和 Droid 项目
  • 关于xamarin.ios - 可移植类库 System.Object 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17766014/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com