简体   繁体   English

DllNotFoundException PInvoke问题

[英]DllNotFoundException PInvoke issue

During tests execution in Visual Studio 2013 (C# code) I have such error: 在Visual Studio 2013中测试执行期间(C#代码)我有这样的错误:

System.TypeInitializationException: System.TypeInitializationException: The type initializer for 'Teigha.Core.GlobalsPINVOKE' threw an exception. System.TypeInitializationException:System.TypeInitializationException:'Teigha.Core.GlobalsPINVOKE'的类型初始值设定项引发异常。 ---> System.TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception. ---> System.TypeInitializationException:'SWIGExceptionHelper'的类型初始值设定项引发了异常。 ---> System.DllNotFoundException: Unable to load DLL 'TD_SwigCore_4.00_10.dll': The specified module could not be found. ---> System.DllNotFoundException:无法加载DLL'TD_SwigCore_4.00_10.dll':找不到指定的模块。 (Exception from HRESULT: 0x8007007E). (来自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). 在构建期间,所有dll都被复制到TestResults \\ Deploy目录(也是TD_SwigCore_4.00_10.dll)。

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. 检查此dll的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 ). 我将所有这些dll复制到system32文件夹,以便加载所有dll( https://msdn.microsoft.com/en-us/library/7d83bc18 ( v=vs.120 ).aspx)。 This doesn't help. 这没有用。 Error still exists. 错误仍然存​​在。

Solution for this issue was to copy missing dlls to directory: {Visual_project_directory}\\bin\\Debug. 解决此问题的方法是将缺少的dll复制到目录:{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. 通过使用dumpbin(它与Visual Studio,在其中一个目录中安装)或Dependency Walker可以找到丢失的dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM