我做了一个快速搜索,得到了这个链接From StackOverflow
我得到这个错误消息“未知错误(0x80005000)”当它点击
bool canCreate = !(schema.Properties["Syntax"].Value.ToString().ToUpper() == "BOOLEAN");我的要求是创建一个虚拟目录,并将AccessRead、IsolationMode、脚本和可执行文件、ApplicationProtection设置为媒体。
让它正常工作,这是代码:
注意:我仍然无法让它在windows 7上工作,它会引发相同的错误,并且消息包括对System.InterOp的引用.现在我不关心让它在windows 7上工作,我把它部署在windows 2003上,它可以工作。
public void CreateVirtualDirectory(string virtualdirectory, string physicalpath)
{
try
{
///check if path exists
if (!Directory.Exists(physicalpath))
{
Log(string.Format(@"CreateVirtualDirectory; Path not found - {0}", physicalpath));
return;
}
DirectoryEntry parent = new DirectoryEntry(string.Format("IIS://{0}/W3SVC/1/Root", Environment.MachineName));
foreach (System.DirectoryServices.DirectoryEntry v in parent.Children)
{
if (v.Name == virtualdirectory)
{
try
{
parent.Invoke("Delete", new string[] { v.SchemaClassName, virtualdirectory });
}
catch
{
}
}
}
DirectoryEntry newFolder = (DirectoryEntry)parent.Invoke("Create", "IIsWebVirtualDir", virtualdirectory);
newFolder.InvokeSet("Path", physicalpath);
newFolder.Invoke("AppCreate", false);
newFolder.InvokeSet("AppFriendlyName", virtualdirectory);
const int MEDIUM_POOL = 2;
newFolder.Properties["AccessRead"][0] = true;
newFolder.Properties["AccessExecute"][0] = true;
newFolder.Properties["AccessWrite"][0] = false;
newFolder.Properties["AccessScript"][0] = true;
newFolder.Properties["AuthNTLM"][0] = true;
newFolder.Properties["AppIsolated"].Clear();
newFolder.Properties["AppIsolated"].Add(MEDIUM_POOL);
newFolder.CommitChanges();
}
catch (Exception ex)
{
Log(string.Format(@"CreateVirtualDirectory '{0}' failed; {1}", virtualdirectory, ex.Message));
}
}发布于 2011-11-11 01:36:41
您正在使用DirectoryEntry创建需要在IIS中安装/配置IIS模式的网站。如果您使用的是IIS6或更高版本,则这是IIS7目录条目接口的复合模式。
如果没有安装,你将得到80005000。
如果您使用的是IIS7或更高版本(Windows 2008或Vista及更高版本),较新的(非compat模式)方法是新的托管Microsoft.Web.Administration。
http://blogs.msdn.com/b/carlosag/archive/2006/04/17/microsoftwebadministration.aspx
https://stackoverflow.com/questions/8088438
复制相似问题