Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using pinvoke, what is the base path for a dll when only the dll name is provided?

I'm calling the following from c#:

[DllImport("u3dapi10.dll", CharSet=CharSet.Auto)]
public static extern uint dapiCreateSession(out uint hSession);

Where is .NET looking for the u3dapi10.dll file? This was working previously but now I'm getting a DLLNotFoundException.

The u3dapi10.dll file is in the root directory of the project. I tried copying it to the bin/debug directory just to see what happens, but it couldn't find it there either.

Possible cause: Could this be caused by the u3dapi10.dll not being 64-bit compatible? e.g. Is a DllNotFoundException thrown if you try to access a 32-bit dll from a 64-bit machine? Or would it throw a BadImageFormatException as suggested by BadImageFormatException when loading 32 bit DLL, target is x86

like image 853
Jason Avatar asked May 11 '11 21:05

Jason


1 Answers

See: Specify the search path for DllImport in .NET

and

http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx

like image 151
John Ruiz Avatar answered Nov 05 '22 15:11

John Ruiz