- Home /
How to use Unity's mono to compile in MonoDevelop
I want to create a .dll to use in Unity, by using MonoDevelop. Since my code makes use of the default arguments feature I am forced to use .NET 4.0 for compiling. If I compile that way however, then Unity throws an error when accessing classes in the .dll. (Error : "Could not load type .. from assembly..").
Now I did some research and I think the reason is that Unity simply doesn't support .NET 4.0 assemblies. However if there is a different solution to my problem, please let me know!
OK since I believe 4.0 is the problem, and 3.5 throws errors at the default arguments, I wanted to know if it's possible to use the compiler that Unity uses. So basically what I want to achieve is, when I click build in Monodevelop, that not microsoft's compiler is run to create my .dll, but Unity's fork of Mono. I believe this might solve my problem, but again I'm not sure.
Answer by Tanshaydar · Oct 23, 2014 at 12:08 PM
I'm not really sure as how you proceed to create these DLLs, as I didn't have any real trouble creating mine DLLs.
These two links might be helpful:
http://forum.unity3d.com/threads/publishing-content-to-the-asset-store-using-dll-files.104517/#post-689272 http://docs.unity3d.com/Manual/UsingDLL.html
I followed them myself, and it worked. But then again, I am not really sure what's causing your problem.
Edit: Oh I see, it is a version problem. I didn't try to compile with higher .Net versions.
I've landed on those links multiple times and unfortunately are not of any help. $$anonymous$$ain problem: if I build my dll with as target platform $$anonymous$$ono/.NET 4.0 then I can't use the dll in Unity. If I target .NET 3.5 then it does work but default parameters for instance is a feature available in mono and .NET 4.0 but not in .NET 3.5.
Sorry, I misread the question about the version thing. I never tried with higher versions. Answer below is correct.
Yeah I found it rather hard to explain my problem, but thanks anyway for taking your time to look up those links.
Answer by screenname_taken · Oct 23, 2014 at 12:12 PM
Unity so far supports just .NET 2.0. The development team said that they are working on a solution to the issue to support a higher version, but that is to come with Unity 5.x
I understand that, but the compiler that Unity uses to compile C# scripts makes use of a modified $$anonymous$$ono that does allow for instance the default parameters feature. So if I would be able to compile my dlls using the Unity compiler isn$$anonymous$$d of the $$anonymous$$icrosoft compiler I think it should work. (Or I want at least give that a try) But I can't figure out how to properly use that compiler to create a dll