简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM