目录

问题案例

原因分析

解决问题

总结

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⊙ )哇

相关文章:

  • 2021-10-29
  • 2021-11-11
  • 2021-06-12
  • 2022-01-22
  • 2021-09-05
  • 2021-07-03
猜你喜欢
  • 2021-06-12
  • 2021-12-04
  • 2021-06-19
相关资源
相似解决方案