- Home /
Why do DLLs have to comply with .NET 2?
I just wanted to ask what the difference for DLLs in comparison to Unity native compiled code is?
I just starting creating a DLL with one extension method in it and Unity did not like it, saying reflections could not make anything out of the method. Extension methods work within Unity however.
How to tell what's working and what is not? Or is somehow cross compiled under the hood?
If you created an extension method inside a dll, did you actually:
placed the compiled DLL somewhere inside your asset folder?
add a
using YourDLLNameSpace;
on top of the script where you want to use that extension method?
Thanks for the suggestion, but the error occurs on import not on usage.
Answer by Dave-Carlile · Apr 22, 2016 at 10:53 PM
You mean from code? It just compiles them?
For your dll makes sure you've set it to compile to .NET 2.0 (or 3.5) in the project settings.
Yeah, thanks, that's exactly what I found out about a $$anonymous$$ute ago :) And it has to be 3.5, because that's when extension methods got introduced
Answer by Dave-Carlile · Apr 21, 2016 at 08:36 PM
Unity doesn't use Microsoft's .NET implementation, but an older version of Mono which covers .NET 2 - 3.5ish.
Edit: For your dll make sure you've set it to compile to .NET 2.0 (or 3.5) in the project settings.
but how does it accept extension methods in scripts in Unity but not from DLLs?
Your answer
![](https://koobas.hobune.stream/wayback/20220612075334im_/https://answers.unity.com/themes/thub/images/avi.jpg)