c#web服务器 虚拟目录,C# WEB 创建IIS虚拟目录报错:“未知名称。 (异常来自 HRESULT:0x80020006 (DISP_E_UNKNOWNNAME)) ”...

#1

看见网上其他人写的加了一句声明,就是多了一个新实例,

DirectoryEntry basic = new DirectoryEntry(stNewPath);

放在DirectoryEntry basic = new DirectoryEntry(stBasicPath, "administrator", "dfasasdasdfd", AuthenticationTypes.Secure ¦ AuthenticationTypes.None)之下。

结果报错如下:

“/”应用程序中的服务器错误。

--------------------------------------------------------------------------------

拒绝访问。

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Runtime.InteropServices.COMException: 拒绝访问。

源错误:

行 36:             if (basic == null) { throw new Exception("the basic " + stBasicPath + " is null,please try a later aglin"); }

行 37:             DirectoryEntry en = new DirectoryEntry(stNewPath);

行 38:             DirectoryEntry obj = basic.Children.Add(folderProperty.stName, "IIsWebVirtualDir");

行 39:             obj.Properties["Path"][0] = folderProperty.stPath;

行 40:             obj.Invoke("AppCreate", true);

源文件: d:\test_project\App_Code\System_IIS.cs    行: 38

堆栈跟踪:

[COMException (0x80070005): 拒绝访问。

]

System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +610

System.DirectoryServices.DirectoryEntry.Bind() +36

System.DirectoryServices.DirectoryEntry.get_IsContainer() +31

System.DirectoryServices.DirectoryEntries.CheckIsContainer() +13

System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName) +13

VirtualDirectory.create_VirtualDirectory(Properties folderProperty) in d:\test_project\App_Code\System_IIS.cs:38

Test.page_load() in d:\test_project\Test.aspx.cs:23

System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) +5

System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +781887

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +47

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

--------------------------------------------------------------------------------

版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值