C# dll problem in windows 7
I'm having exactly the same problem as the poster in this question. I have a visual studio C# projects from which I'm trying to call a function in another DLL (which is also part of the solution).
The DLL is a C++ one and the exported function I'm trying to call is declared like this in C#:
[DllImport("SomeDLL.dll")]
private extern static IntPtr SomeFunction(IntPtr someVar1, IntPtr someVar2, bool someVar3);
When I try to call the function from C# I see the following on the console output in the debugger:
'MyApp.exe': Loaded 'C:\SomePath\Build\Eddy\Debug\SomeDLL.dll'
'MyApp.exe': Unloaded 'C:\SomePath\Build\Eddy\Debug\SomeDLL.dll'开发者_运维问答 'MyApp.exe': Loaded 'C:\SomePath\Build\Eddy\Debug\SomeDLL.dll' 'MyApp.exe': Unloaded 'C:\SomePath\Build\Eddy\Debug\SomeDLL.dll'
And I the get the following error dialog:
Unable to load DLL 'SomeDLL.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
The code in question works fine on my colleagues windows XP machine. There's also another C++ DLL in the solution which works fine.
The problem seems to be that SomeDll.dll cannot be loaded. There are a few different reasons for why this may happen and some of them are:
- The dll is 32-bit and you are running a 64-bit process (or the other way around).
- SomeDLL.dll has some additional dependencies (other dll:s or COM components) that are not available.
You can run Dependeny Walker: http://www.dependencywalker.com/ on your somedll.dll to see if it is point 2 that is the problem.
精彩评论