AccessViolationException:尝试读取或写入受保护的内存 - 使用DirectoryEntry进行IIS访问

时间:2013-03-20 16:28:57

标签: c# iis access-violation directoryentry

我试图使用以下代码在IIS中的Web应用程序下找到一个文件夹,我遇到了以下错误:

AccessViolationException: Attempted to read or write protected memory.

我试过的代码如下:

DirectoryEntry entry2 = new DirectoryEntry(string.Format("IIS://{0}/W3SVC/{1}/Root/{2}", serverName, siteID, parentVirDirName));
entry2.RefreshCache();
DirectoryEntry entry3 = entry2.Children.Find(folderToSearch);

错误发生在上面代码的最后一行。 任何帮助或线索摆脱这一点是非常感谢

0 个答案:

没有答案