DLL issues

Hello,

Im trying to create a dll for the Editor and even though the library im making is targetting .Net 2.0 and has included references to both UnityEngine.dll and UnityEditor.dll from the managed folder I get this error and doesn’t compile:

“Error 8 The type or namespace name ‘UnityEditor’ could not be found (are you missing a using directive or an assembly reference?)”

I think it goes away if I target 4.5 .Net but then I get reflection issues in the editor

How do you compile the dll?

In release mode from visual studio as a class library project

Sorry, can’t help with Visual Studio.

The logic behind it should be the same as in mono no?

Yes, you are right. But the error message sounds a little weird. I can’t remember that I ever had such an error message. I am not using MonoDevelop to create dlls, but a custom solution, but even like that, it is technically the same.

Are you really sure that the UnityEditor.dll is referenced correctly?
Did you try to create a web player build of your project? If there is an issue with one of the scripts, you may only find it when you create an actual build as otherwise the editor won’t show any error messages.

  1. I made an empty custom MonoBehavior called Test, and Unity compiled it into Assembly-CSharp.dll
  2. Then I created a class library project targeting .Net 3.5.
  3. Added three assembly references: UnityEngine.dll, UnityEditor.dll, Assembly-CSharp.dll
  4. Made a custom editor for my Test script.
  5. Compiled it into TestEditor.dll
  6. Moved TestEditor.dll to Editor folder inside my Unity project.

That’s it.

It’s an Editor dll that I am making to extend the UnityEditor, so I dont need to build or switch platforms, I am in the basic PC/Mac/Linux setting but I dont get there as the project doesnt compile to create the dll because it says it cant find the unityEngine.dll in 2.0 but it does in 4.5, which is weird

It is only possible to find issues editor and non editor scripts by creating a build. You may create a build for any platform, just to test whether there is an issue or not. I am proposing weird ideas, because the error message sounds like that as well.
But anyway, it seems that alexzzzz has more experience with creating dlls within an IDE.

alexzzz so how come the library class can be more than .net 2.0?

I don’t know, what “.Net 2.0” and “.Net 2.0 Subset” actually mean in Unity, but I do know that Microsoft .Net Framework 2.0, 3.0 and 3.5 - all three of them use the same version of runtime - CLR 2.0. Therefore there’s no really much difference between targeting 2.0 or 3.5.

ok it seems it compiled properly in 3.5 and not in 4.5 or 2.0, must be a windows 7 and 8 thing?

You find the difference between .net and .net subset here:

For your situation, it should not be relevant, as it is all about which api is available at runtime.

I was about to link that :slight_smile: But yeah irrelevant to mine

Finally to call the method i want, do I need to use proxies? or just external because when i do extern I get that it doesnt find the method I m calling for

I get EntryPointNotFoundException

In the end I didnt use proxies or externs as I think C# scripts aren’t thought of as plugins rather as similar scripts

Yes, you are right. Managed dlls can be accessed like any regular script without the need to use proxies. This is only needed for native plugins (C/C++/Objective C, …).