DirectoryEntry配置IIS出现ADSI Error:未知错误(0x80005000)

目录

问题案例

原因分析

解决问题

总结

问题案例

DirectoryEntry配置IIS,在IIS6.0下运转正常,但IIS7.0下运转会出错: 

System.DirectoryServices.DirectoryEntry iisServer;
iisServer = 
new System.DirectoryServices.DirectoryEntry("IIS://LOCALHOST/W3SVC/");//此处抛出异常

异常内容如下: 

System.Runtime.InteropServices.COMException (0x80070003): 系统找不到指定的路径。

   在 System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   在 System.DirectoryServices.DirectoryEntry.Bind()
   在 System.DirectoryServices.DirectoryEntry.get_IsContainer()
   在 System.DirectoryServices.DirectoryEntries.ChildEnumerator..ctor(DirectoryEntry container)
   在 System.DirectoryServices.DirectoryEntries.GetEnumerator()

 

原因分析

排除原因 :IIS6的管理兼容性。

因为在 “控制面板”->“程序和功能”->面板左侧“打开或关闭windows功能”->“Internet信息服务”->“Web管理工具”->“IIS 6管理兼容性”。已全部打钩。

有查到资料说是这方面的原因

 

解决问题

 在网上找了各种方式,但是始终不得人意。最后发现了DirectoryEntry的入参有如下区别:

DirectoryEntry appPools = new DirectoryEntry(“IIS://LOCALHOST/W3SVC/”);   //报错
/*
 其他操作
*/

DirectoryEntry appPools = new DirectoryEntry(“IIS://LOCALHOST/W3SVC”);   //正常
/*
 其他操作
*/

 

 

总结

    解决了之后,再看一眼简直惊呆了....真的是一符之差( ⊙o⊙ )哇

转载于:https://www.cnblogs.com/xiaotiannet/p/3435574.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值