简体   繁体   English

MonoTouch编译时错误:System.Boolean System.Type :: op_Equality(System.Type,System.Type)

[英]MonoTouch Error when compiling: System.Boolean System.Type::op_Equality(System.Type,System.Type)

I have a MonoTouch app, when I compile it for the device, I get the following error: 我有一个MonoTouch应用程序,当我为设备编译它时,出现以下错误:

Error MT2002: Can not resolve reference: System.Boolean System.Type::op_Equality(System.Type,System.Type) (MT2002)

It works fine in the simulator, however occasionally I'll get a MissingMethodException with the same type. 它在模拟器中可以正常工作,但是偶尔我会得到一个具有相同类型的MissingMethodException

I have no 3rd party libraries. 我没有第三方图书馆。 All of the code is my own. 所有的代码都是我自己的。 Any ideas? 有任何想法吗?

Edit Here are my 3 projects and all their references. 编辑这是我的3个项目及其所有参考。

Project 1: Mobile.Libraries 项目1:Mobile.Libraries

  • monotouch MonoTouch的
  • System 系统
  • System.Core System.Core程序
  • System.Xml 的System.Xml

Project 2: Mobile.Core 项目2:Mobile.Core

  • Mobile.Libraries 移动图书馆
  • System 系统
  • System.Core System.Core程序
  • System.Xml 的System.Xml

Project 3: Mobile.IOS 项目3:Mobile.IOS

  • monotouch MonoTouch的
  • Mobile.Core 移动核心
  • System 系统
  • System.Core System.Core程序
  • System.Xml 的System.Xml

Like @Jonathan.Peppers said this occurs when you use a compiled .dll that was built against the full, .NET4, profile. 就像@ Jonathan.Peppers所说的,当您使用针对完整.NET4配置文件构建的已编译 .dll时,就会发生这种情况。

MonoTouch Base Class Libraries (BCM) provides a superset of the Silverlight profile (2.1) with some 4.0 additions. MonoTouch基类库(BCM)提供了Silverlight配置文件(2.1)的超集,并增加了4.0。 So adding pre-compiled binaries from another framework can requires some types/methods that are not present in MonoTouch BCL. 因此,从另一个框架添加预编译的二进制文件可能需要MonoTouch BCL中存在的某些类型/方法。

The solution is to rebuild all your .dll against the BCL assemblies that are shipped with MonoTouch. 解决方案是根据MonoTouch附带的BCL程序集重建所有.dll。 That will ensure the compiler will only uses symbols that are available. 这样可以确保编译器仅使用可用的符号。

Why does it works on the iOS simulator ? 为什么它可以在iOS模拟器上运行?

That's because the JIT is used. 那是因为使用了JIT。 Since it's compiled Just In Time you might never reach the missing symbols so it can work until you hit the missing code (and get a runtime error). 由于它是按时编译的,因此您可能永远不会到达缺少的符号,因此它可以起作用,直到您遇到缺少的代码(并获得运行时错误)。

On the other hand when you use the device (or the linker) then all the symbols are loaded (and compiled for AOT). 另一方面,当您使用设备(或链接器)时,所有符号都会被加载(并为AOT编译)。 Anything missing will be found ahead of time so you get an build-time error like the one above. 任何丢失的东西都会提前发现因此您会遇到类似上面的构建时错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM