Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在ASP.NET项目中放置本地dll的位置?_C#_Asp.net_Exception_Dll_Pinvoke - Fatal编程技术网

C# 在ASP.NET项目中放置本地dll的位置?

C# 在ASP.NET项目中放置本地dll的位置?,c#,asp.net,exception,dll,pinvoke,C#,Asp.net,Exception,Dll,Pinvoke,我有一个ASP.NET项目,需要pinvoke执行以下功能: [DllImport("NetSh.dll")] public static extern int RunAsUsr(string pcs_admin, string pcs_user, string pcs_password); 问题是调用函数时出现以下异常: [DllImport("NetSh.dll")] public static extern int RunAsUsr(string pcs_admin, string pc

我有一个ASP.NET项目,需要pinvoke执行以下功能:

[DllImport("NetSh.dll")]
public static extern int RunAsUsr(string pcs_admin, string pcs_user, string pcs_password);
问题是调用函数时出现以下异常:

[DllImport("NetSh.dll")]
public static extern int RunAsUsr(string pcs_admin, string pcs_user, string pcs_password);
无法加载DLL“NetSh.DLL”:无法加载指定的模块 建立来自HRESULT的异常:0x8007007E

那么,为了避免异常,我必须将dll放在哪里?目前,dll位于my.aspx文件的同一目录中。

它应该位于web应用程序根目录的bin文件夹中,因为.Net程序集也位于bin文件夹中


对于web应用程序,.Net将在其中搜索文件\configs\etc。对于windows应用程序,它将与exe应用程序所在的文件夹相同。

默认情况下,您应将其放在项目的bin文件夹中。如果出于某种原因,您不希望它出现在那里,您还可以在DLLIMPORT语句中指定DLL的路径