Equality and Inequality operators not found in DLL ???

Hey there !

So here’s the problem… After some refactoring to remove default operators so that it compiles well, now I get some new funny errors when trying to use it. I get MissingMethodExceptions all over the places for pretty much all reflection types.

At first, I had trouble with == operator for Type class. I still don’t understand why that didn’t work since Equals method was implemented, but whatever.
Now I have trouble with MemberInfo == operator, and that’s like really really boring. Isn’t it the C# standard behaviour for == operator to call object’s ReferenceEquals method if it was not explictly implemented by derived class ? (which is pretty much all I need since I use that for null check)

There’s definitely something I don’t understand there. Thousands things work in Unity (like default arguments, aforementioned operators…) and just don’t work when you build it in a DLL. Just what’s the logic behing that ? Is there something I’m doing wrong ?

Thanks in advance for your answers.

Ok, after further investigation, I was finally able to understand why I had those problems.

I checked projects settings in MonoDevelop, and it appeared that target framework was Mono/.NET 4.0 by default. I didn’t want that, but that’s just how it was.
== operator for Type, MemberInfo etc. were implemented in .NET 4 and later. So it appears that when compiling my code for Mono/.NET 4, it was looking for == operator of those types instead of just using object’s, which resulted in runtime errors because it was trying to use an operator that wasn’t implemented yet in Mono/.NET 3.5 which Unity uses.

Now I compile for Mono/.NET 3.5 and it works just fine !!! :slight_smile: