-1

I develop application in c# which contain c++ dll. I import the dll using DllImport. My application work properly in my system. But when i test application from different system it will throw

"Unable to load dll Exception"

and in catch block it will display error

"Dll not found"

I also print the path using

System.IO.Path.GetFullPath("abc.dll")

and i put the dll in return path. Now what is the solution ? so i can run application from different system. Thanks inadvance.

MatSnow
  • 7,357
  • 3
  • 19
  • 31
Siddhi Dave
  • 67
  • 1
  • 8
  • 1
    Possible duplicate of [Unable to run c#application (using c++ dll) in some PCs](https://stackoverflow.com/questions/4992614/unable-to-run-capplication-using-c-dll-in-some-pcs?rq=1) – Bo Persson Sep 12 '17 at 12:49

2 Answers2

0

Copied below solution from - https://forums.asp.net/t/939729.aspx?Unable+to+load+DLL+foo+dll+The+specified+module+could+not+be+found+Exception+from+HRESULT+0x8007007E+

You need to figure out which managed dll, native dll and lib files are referenced by your application (directly or indirectly).

For managed dll, make sure they are in the web's bin folder.

For native dll and .lib files, check out whether those .dll and .lib files are in the PATH. If not, you can either copy them to there; or, you can put them into a folder and add that folder into the PATH. Then restart VS and IIS (command "iisreset") to make sure the setting is picked up.

In that solution he has reproduced this error using the following sample solution

  1. Web1 references a managed c++ project say "MCpp1.dll". The project further references two unmanaged c++ projects with the output say "Lib1.lib" and "Lib2.lib"

  2. If I copy all of those files into web's bin folder, I get the exception of "module not found error".

  3. I create a folder say "C:\Lib" and copy "Lib1.lib" and "Lib2.lib" into it and add this folder into PATH. I restart VS, and also run "IISReset" since I have a IIS web

  4. Open VS and request a page and it works now

Vijayanath Viswanathan
  • 8,027
  • 3
  • 25
  • 43
0

May be you should check Project Properties->Linker->Input or Additional Library Directories for which contain your c++ dll path.

  • Yes i add add "Additional Dependancy". If i do not mention "Additional Dependancy" then it will throw exception "error LNK2019: unresolved external symbol __imp__ referenced in function " – Siddhi Dave Sep 13 '17 at 04:06