Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DllNotFoundException PInvoke issue

During tests execution in Visual Studio 2013 (C# code) I have such error:

System.TypeInitializationException: System.TypeInitializationException: The type initializer for 'Teigha.Core.GlobalsPINVOKE' threw an exception. ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'TD_SwigCore_4.00_10.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E). Aborting test execution.

My friend uses the same code branch on another computer. He has no such problems. All dll's are copied to TestResults\Deploy directory during build (TD_SwigCore_4.00_10.dll too).

I used

dependbin /DEPENDENTS TD_SwigCore_4.00_10.dll

to check dll dependents of this dll: KERNEL32.dll, USER32.dll, ole32.dll, TD_Ge_4.00_10.dll, TD_DbRoot_4.00_10.dll, TD_Gi_4.00_10.dll , TD_Gs_4.00_10.dll , TD_SpatialIndex_4.00_10.dll, TD_Br_4.00_10.dll, TD_Db_4.00_10.dll, TD_Root_4.00_10.dll, TD_Alloc_4.00_10.dll, MSVCP100.dll, MSVCR100.dll. I copied all this dlls to system32 folder so that all dlls would be loaded (https://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.120).aspx). This doesn't help. Error still exists.

like image 553
Zygmuntix Avatar asked Oct 27 '25 08:10

Zygmuntix


1 Answers

Solution for this issue was to copy missing dlls to directory: {Visual_project_directory}\bin\Debug. Files cannot be hidden inside some directories, they have to be copied straight into this directory. Missing dlls can be found by using dumpbin (it is installed with Visual Studio, in one of its directories) or Dependency Walker.

like image 50
Zygmuntix Avatar answered Oct 31 '25 02:10

Zygmuntix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!