- Home /
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.
In a separate solution in $$anonymous$$onoDevelop yeah. It builds well, it's just not working when I call my code from script. (I get those weird $$anonymous$$issing$$anonymous$$ethodException I was talking about)
I know I'm saying the same thing too much in this answers page but, it may be about API compatibility level. Please try to set the API level in the player settings to full .net (not the subset)
If this fixes your problem, still you don't have to use the full .net level. You can use the subset level but I think you should build your dll compatible with subset level. I don't know if there is a setting in $$anonymous$$onoDevelop to be able to build it that way.
Erf, no luck. That doesn't seem to change anything. I still get exceptions. Thanks for your answer though :)
Definitely, that's weird. Unity does build Editor and Runtime assemblies with default arguments, equality operators etc. so there must be a way to do build all that in a custom DLL. I really wonder what I'm doing wrong.
if you can prepare a small assembly project that has the same issue, I can try to build it and add it to unity.
Answer by DocteurCox · Aug 08, 2013 at 12:00 PM
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 !!! :)
Yea totally! When I suggested you to check the Unity's API level, I assumed you were building it for the correct .net version already. Anyway, good to hear it's working now.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Does a DLL work in an iOS build? 1 Answer
Why is the 'Run' button in Monodevelop is grayed out? 1 Answer
Build error when using BooleanOps.dll 1 Answer
Build itextsharp dll Lite 1 Answer