- Home /
Use .NET native dll calls
Hi, recently i doing a little crazy stuff with unity. so what I do is copy a .NET assemblies (System.Management) to unity Plugins folder. then, I trying to test it within my project using this code:
ManagementObjectSearcher searcher = new ManagementObjectSearcher (
WMINamespace,
"SELECT " + Member + " FROM " + WMIClass + " " + AddQuery);
but suddenly, when i try that script, unity crashed even when i debug my script from MonoDevelop. even when i build the project, unity fail to compile the .NET assembly inside Plugins folder.
so is there anybody have tried this crazy stuff? cause as far as i know that Unity are using mono Assemblies, and from mono documentation says, System.Management
are not included in their assemblies.
There might be a conflict between Unity's $$anonymous$$ono libraries and .Net's dll. It might help others to answer if you post the exact error you are getting and what version of Unity you are using.
ok, the error says it's an access violation (when i run inside editor), but I can't debug this error. also I try both 4.6 and 5.0 still have same error.
Have this worked before on any versions of unity?. What I've done before (with unity Pro) was to create custom dlls and use them within unity project. But according to this .net Assembly / Class definition, it tries to get System information (like network , drives, and so on). Since unity has a subset of the .net libraries, and strictly speaking it looks like a client side technology, not sure if this specific class may be available within it. Have you tried with another dll?
Answer by SirAstral · Mar 27, 2015 at 12:36 AM
If you are trying to do what I am doing, you cannot just import .Net DLL class libraries. You need to first set Unity API Compatibility Level to .NET 2.0 instead of .NET 2.0 subset.
Unless you are doing something weird by all account Unity does not support anything higher than .Net 3.5 dll's being imported. So if you are like me and trying to build a WebPlayer bases application that needs to use this, then you are just flat out of luck unless you build an entire class from pure scratch to support it. This tool would make a beastly application platform if Unity would just get their act together with .Net support. It is shocking that a lot of organizations just do not keep up to date support for .Net in their products properly... Microsoft including and its their own product. Shocker there right?
http://answers.unity3d.com/questions/932874/adding-service-references.html
thanks!, now i can run and build my project. to make unity are not crashed, I need to reference my script as DLLs
but there is new problem, Unity gives me new Error :
NotImplementedException: The requested feature is not implemented.
System.$$anonymous$$anagement.$$anonymous$$anagementObjectSearcher..ctor (System.String scope, System.String queryString)
(wrapper remoting-invoke-with-check) System.$$anonymous$$anagement.$$anonymous$$anagementObjectSearcher:.ctor (string,string)
W$$anonymous$$IPort.WmiGetValue (System.String W$$anonymous$$INamespace, System.String W$$anonymous$$IClass, System.String $$anonymous$$ember, Int32 Index, System.String AddQuery)
W$$anonymous$$IPort+<loop>d__0.$$anonymous$$oveNext ()
UnityEngine.$$anonymous$$onoBehaviour:StartCoroutine(IEnumerator)
W$$anonymous$$IPort:Start()
and i see that i'm use .NET version 4.0, how I can insert .NET Dlls version 2.0? it should be exist somewhere.
okay, I found it on %windir%\$$anonymous$$icrosoft.NET
, but it still gives me same error.
look like I'm out of luck.
There are a lot of areas you can find DLL's to import. Windows, Program Files they have several directories holding .net libraries.
If you are looking for the proper version of System.$$anonymous$$anagement.dll try here
Program Files (x86)\Reference Assemblies\$$anonymous$$icrosoft\Framework.NETFramework\v3.5\Profile
Hope this helps!
hmmm, i the Profile
folder isn't exist for me,
but any way, your answer is enough to solve my problem, i just make little experiment with unity, and look like it's won't be supported in unity since it's a cross platform.
Your answer
Follow this Question
Related Questions
Game Thrive (One Signal) causes game to crash when calling init method. 1 Answer
Trying to use SDK as plugin that compiled with .NET Framework 4.0 in Unity 1 Answer
Most consistent way to handle Timezones (plus JNI help) 2 Answers
GoogleVR on Unity has error can't load libaudioplugingvrunity 0 Answers
Editor crashes on second play 2 Answers