Nick
Nick

Reputation: 10499

Where to place local dll in a ASP.NET project?

I have a ASP.NET project where I need to pinvoke the following function:

[DllImport("NetSh.dll")]
public static extern int RunAsUsr(string pcs_admin, string pcs_user, string pcs_password);

The problem is that i get the following exception when I call the function:

Unable to load DLL 'NetSh.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

So, where I have to place my dll in order to avoid the exception? At the moment the dll is in the same directory of my .aspx files.

Upvotes: 3

Views: 608

Answers (2)

CrazyBernie
CrazyBernie

Reputation: 174

By default you should put in the Bin folder of your project. if for some reason you do not want it there you could also specify a path for the DLL in the DLLIMPORT statement.

Upvotes: 1

Sergey Litvinov
Sergey Litvinov

Reputation: 7458

It should be in bin folder in the root of your web app as your .Net assemblies are also located in the bin folder.

For web apps bin folder is default where .Net will search for files\configs\etc. For windows app it will be the same folder where exe app is located.

Upvotes: 4

Related Questions