调用DirectoryEntry.Find(), 查找一个IIS的虚拟目录出错.

qinglinmeng 2003-06-10 12:54:02
s = "Test";

DirectoryEntry rootfolder = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry newVirDir = rootfolder.Children.Add(s,"IIsWebVirtualDir");
newVirDir.Properties["AnonymousUserName"][0] = rootfolder.Properties["AnonymousUserName"][0] ;
newVirDir.Properties["AnonymousUserPass"][0] = rootfolder.Properties["AnonymousUserPass"][0];
newVirDir.Properties["AccessRead"][0] = true;
newVirDir.Properties["AccessExecute"][0] = true;
newVirDir.Properties["AccessWrite"][0] = false;
newVirDir.Properties["AuthBasic"][0] = false;
newVirDir.Properties["AuthNTLM"][0] = true;
newVirDir.Properties["ContentIndexed"][0] = false;
newVirDir.Properties["EnableDefaultDoc"][0] = true;
newVirDir.Properties["EnableDirBrowsing"][0] = false;
newVirDir.Properties["AccessSSL"][0] = false;
newVirDir.Properties["AccessScript"][0] = true;
newVirDir.Invoke("AppCreate",true);
newVirDir.Properties["DefaultDoc"][0] = "default.asp";
newVirDir.Properties["Path"][0] = "c:\\";
newVirDir.CommitChanges();
rootfolder.CommitChanges();
newVirDir.Close();
rootfolder.Close();


DirectoryEntry rootfolder2 = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry newVirDir2 = rootfolder2.Children.Find(s, "IIsWebVirtualDir");

产生异常

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.directoryservices.dll

Additional information: Exception from HRESULT: 0x80005008.

调试发现目录创建成功, 在执行FIND的时候出错.

谢谢
...全文
44 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyear 2003-06-13
  • 打赏
  • 举报
回复
mark
qinglinmeng 2003-06-13
  • 打赏
  • 举报
回复
我是用的是1.0 + VS 2002, 可能这是一个BUG吧.
但我想安装1.1的RUNTIME的时候, 无法安装, 你知道怎么才能升级吗? 是不是我要把原来的先删除, 再来安装?
谢谢
wunanyong 2003-06-12
  • 打赏
  • 举报
回复
是framework1.1, vs2003
wunanyong 2003-06-11
  • 打赏
  • 举报
回复
我在我的机器上试了
好消息是程序没问题,返回结果也对
坏消息是你异常的原因我就不知道了:)
qinglinmeng 2003-06-11
  • 打赏
  • 举报
回复
多谢fyy117()帮助UP.

多谢wunanyong(), 能告诉我你的机器的软件环境吗? 你用的是1.1还是1.0的RUNTIME?
fyy117 2003-06-11
  • 打赏
  • 举报
回复
up
qinglinmeng 2003-06-11
  • 打赏
  • 举报
回复
请大家帮忙, 或者提供你们的解决方案. 多谢了.

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧