Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MonoTouch error MT2002: Can not resolve reference

I'm working on a iOS/MonoTouch project which is using a lot of reflection. Everything works great, but when I compile the Debug|iPhone version I get the error:

error MT2002: Can not resolve reference: System.Boolean System.Reflection.PropertyInfo::op_Equality(System.Reflection.PropertyInfo,System.Reflection.PropertyInfo)

Funny thing is that the Release|iPhone build works fine.

What can be wrong?

like image 239
Marcel W Avatar asked Apr 07 '12 16:04

Marcel W


1 Answers

The == operator overload for PropertyInfo, which is internally named op_Equality, is available on .NET 4.0 and later. IOW it's not available in the version of mscorlib.dll that ships with MonoTouch (which is a superset of the Silverlight, 2.1, profile).

What's happening is likely a different version of a pre-compiled assembly that is used when building Debug (versus Release). This version uses methods that are not available in MonoTouch and this will results in errors while either linking or AOT-ing your application.

Solution: re-compile this assembly with the version of mscorlib.dll that ships with MonoTouch. This will avoid the reference to op_Equality (and uses Equals) and the build should work fine.

like image 177
poupou Avatar answered Sep 20 '22 12:09

poupou