I want to use in my C# metro app function from C++ library
I'm trying to do it as usual [DllImport("MyLibrary.dll")]
and put the dll in bin\debug folder of the application.
when it run I get an exception "Unable to load DLL 'MyLibrary.dll'
: The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
What can I do please?

- 31,624
- 6
- 74
- 100

- 429
- 1
- 9
- 19
3 Answers
You may have a dependency on an assembly that only exists for 32-bit or hasn't been properly installed in the GAC. and follow the remarks on the DllImportAttribute Constructor msdn documentation.
Ref:
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
the specified module could not be found 0x8007007E
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Unable to load DLL 'foo.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

- 1
- 1

- 18,017
- 2
- 42
- 75
Is the DLL in your package? Add it to the project and make the type Content. If it is not deployed with your app, you can't use it.

- 18,808
- 8
- 56
- 85
-
2it sounds that - that what i need but how can I do it? it C# application and c++ dll. how to add it to the project? – user758795 May 07 '12 at 10:59
-
In solution explorer, right click project, add existing item, browse to the dll. Then in solution explorer right click the DLL and choose Properties, make sure Content is true. – Kate Gregory May 07 '12 at 13:01
I had some issues with that too. My solution has been rather simple and not given in any other place:
Copy the next two dlls in the same folder:
libgcc_s_dw2-1.dll
libstdc++-6.dlll
I tried to use "mylib.dll" in a cpp coded aplication and the system asked me to include those files. And suddenly, the app I was developing didn't complain any more about not being able to find "mylib.dll". Don't asky me why.
Cheers, Haritz Zabaleta