how to use CLR 2 based DLL in Unity3D?
in Visual Studio 2010, can be done by adding
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
to app.config
what is the correspondent solution in Unity3D?
Thanks a lot!
Unity does not support any .NET 4.0 at all (nor does mono), as such .NET 4.0 and CLR2 stuff is bound to fail.
Compile things for .NET 3.5 at maximum if you intend to go to unity with them
thank you! problem is I was talking about third party dll, not mine:(
Any 3rd party developer that offers such assemblies normally offers 2 assemblies, one for .NET 4.0 and one for .NET 3.5 for exactly this reason.
at least given the functionality was present before, if not then you can’t do anything about it (if it had to do with threading you commonly might want to avoid any third party as you need rather good knowledge on what happens to prevent crashes in context of unity as threaded communication and callbacks / delegates from a different thread will crash unity)
Hi, Dreamora
Thanks for your explanation.
My knowledge about .NET is very limited and I’m brand new to Unity. Here, I’m a bit confused about the CLR version and .NET version. After a while googling, I still am having no clear clue…
I’m trying to stream data from Vicon system to Unity3D. The Assembliy provided by Vicon says the runtime version is 2.0.50727, under Visual Studio 2010 I cannot load it properly without making useLegacyV2RuntimeActivationPolicy equal “true”…so CLR2 means the .NET version it bonds to is lower than .NET4, am I right? or what is the relationship between these two stuff, CLR and .NET?
Thank you very much for your time,
Ruiying
Making it work on VS should be your least interest actually, as VS does not support mono and Unity does not support MS .NET
You should drop the DLL into unity (commonly one drops them into the Plugins folder) and then go on from there, for cases like this Visual Studio is very unsuitable / missleading when it comes to the actual outcome.
For example if the dll internally uses unsafe / unmanaged code, the assembly owuld only work with standalone builds for win or osx (depends on for what it was written, don’t know Vicon) and things like this, which you will not realize nor see any implication within VS, but which will fail instantly in Unity if the project is web or mobile.
Actually I realized that I am incorrect on the CLR part, CLR2 should be fine (had something else in mind :(). Also it seems its targeting .NET 2.0 so if it fails to run in unity (in the editor), please include the errors you get from that end.
yes, I DID drag the dll to project pane, and my script seems having no problem to find it. But while switching to game viewer and play, I get Runtime Error!
R6034
An application has made an attempt to load the C runtime library incorrectly…
Why I mentioned about VS is that in VS I can get it work and stream data in properly…and it is more convenient to check errors…
C runtime library sounds like you forgot to copy along a unmanaged dll into the plugins folder or that you don’t have unity pro, which is a required to use non .net plugins at all
Thanks Dreamora!
I’m using the pro version.
but sorry for naive question, what is the unmanged dll that I should copy along? I had copied DLL from Vicon and msvcp80.dll
msvcr80.dll Microsoft.VC80.CRT.manifest to Unity/Editor folder.
I wasn’t be able to find the plugins folder…
The msvcp80 should never be present in the applications folder, that owuld be extremely slugish. If its required, include the VC++ runtime library installer along your own install.
As for the error and potentially find out what is required otherwise etc, you might have a read on this thread: http://www.eggheadcafe.com/software/aspnet/29300887/r6034-an-application-has-made-an-attempt-to-load-the-c-runtime-lib.aspx
thanks, by removing msvcp80.dll from Editor folder, the R6034 error has gone.
But I get this while initializing Vicon Client:
MissingMethodException: Method contains unsupported native code
<Module>.<CrtImplementationDetails>.LanguageSupport.Initialize (<CrtImplementationDetails>.LanguageSupport* )
<Module>..cctor ()
after a while browsing the forum, I fear that I ran to the real dead end…
ruiying, did u solve this issues? i’m also facing similar problem.
No, I was kinda convinced myself that this can’t be solved without touching the source code of either Vicon’s dll or the core of Unity…
But if you figured out a work-around, please do share with us?
R