Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

How do I use .NET 4.5 managed DLL called by a native DLL

$
0
0
I work on a game and I have to use some .NET 4.5 code but this is *a priori* impossible because the mono version used by Unity is too old. I found this solution: [unmanaged exports][1] to make a native plugin from C# code. And this works well. Unfortunately, my plugin uses other projects compiled as portable libraries. I put these DLLs in the same folder as the native dll. But since they are managed, Unity tries to load them and fails at compilation because they are .NET 4.5 (and worse: Xamarin Portable): Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) I tried to tell Unity not to bother with these DLLs by opting them out but I guess they are not put into the build and as soon as they are loaded in Unity, the editor crashes. I then get this in the Unity logs: ========== OUTPUTING STACK TRACE ================== 000007FEFD37940D (KERNELBASE) RaiseException 000007FEEAF9AA64 (MSVCR120_CLR0400) _ValidateWrite 00000000772F0C51 (ntdll) RtlRestoreContext ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 000007FEE774F25F) 000007FEE774F25F (clr) ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 000007FEE77337A1) 000007FEE77337A1 (clr) ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 000007FEE7733FB6) 000007FEE7733FB6 (clr) ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 000007FEE772225A) 000007FEE772225A (clr) 000007FEE778B42E (clr) GetMetaDataInternalInterface 000000001E9A2435 (Mono JIT Code) (wrapper managed-to-native) Startup:Prepare () 000000001E9A2319 (Mono JIT Code) [E:\USER\GUI_Iriel\Assets\Scripts\Startup.cs:60] Startup:Start () 000000000D136502 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) 000007FEEDC83DF7 (mono) [c:\buildslave\mono-runtime-and-classlibs\build\mono\mini\mini.c:4914] mono_jit_runtime_invoke 000007FEEDBD82A1 (mono) [c:\buildslave\mono-runtime-and-classlibs\build\mono\metadata\object.c:2623] mono_runtime_invoke 000000014039F94F (Unity) scripting_method_invoke 0000000140548BD3 (Unity) ScriptingInvocation::Invoke 000000014037D06F (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked 000000014037D6FC (Unity) MonoBehaviour::InvokeMethodOrCoroutineChecked 000000014037E297 (Unity) MonoBehaviour::Start 0000000140346BF5 (Unity) DelayedCallManager::Update 000000014047387B (Unity) PlayerLoop 0000000140D00947 (Unity) Application::UpdateScene 0000000140D0669D (Unity) Application::EnterPlayMode 0000000140D06F0A (Unity) Application::SetIsPlaying 0000000140D0D02C (Unity) Application::TickTimer 0000000140DC2845 (Unity) SetAppUpdatesPerSecondOSImpl 0000000140DC4EA4 (Unity) WinMain 0000000141387278 (Unity) strerror_s 00000000770959ED (kernel32) BaseThreadInitThunk 00000000772CC541 (ntdll) RtlUserThreadStart ========== END OF STACKTRACE =========== It seems like the DLLs are simply absent, I guess Unity did not pack them in the build, since it is what I specified. Do you know how I could use this code? My first guess would be to find a way to put managed DLL in a build without unity trying to compile them. But I do not know if such a thing exists. [1]: https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>