EDN Admin
Well-known member
Hi All,
Environment: Visual Studio 2008/SQL Server 2005
Operating System: Windows Server 2003
I am using below code to Create and Host Website in IIS.
In first time, Website Created and deleted successfully, While Recreating/Hosting Website in IIS 6.0 throws Error in below Line:
object websiteId = (object)w3svc1.Invoke("CreateNewSite", newsite);
Error:
Message = "Exception has been thrown by the target of an invocation."
Inner Exception: InnerException = The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
[System.Reflection.TargetInvocationException] = {"Exception has been thrown by the target of an invocation."}
DirectoryEntry w3svc1 =new DirectoryEntry("IIS://localhost/W3SVC");
//Create a website object array
object[] newsite = newobject[] { "TelnetProbeService",new object[] { "*:90:" }, "c:Test"};
//invoke IIsWebService.CreateNewSite
object websiteId = (object)w3svc1.Invoke("CreateNewSite", newsite);
w3svc1.Properties["ServerAutoStart"][0] = true;
w3svc1.Properties["AuthNTLM"][0] =true;
w3svc1.Properties["AccessScript"][0] =true;
w3svc1.Properties["AccessFlags"][0] = 513;
w3svc1.Properties["AuthAnonymous"][0] =true;
w3svc1.Properties["AccessRead"][0] =true;
w3svc1.Properties["AccessWrite"][0] =false;
w3svc1.Properties["AccessScript"][0] =true;
w3svc1.Properties["AppPoolId"].Value =@"DefaultAppPool";
w3svc1.CommitChanges();
I am using below code to Delete Website in IIS.
DirectoryEntry w3svc =new DirectoryEntry("IIS://localhost/W3SVC","SYNAPSErcatsadmin", "Global@123", AuthenticationTypes.Anonymous);
foreach (DirectoryEntry serverin w3svc.Children)
{
if (server.SchemaClassName == "IIsWebServer")
{
if (server.Properties["ServerComment"][0].ToString() =="TelnetProbeService")
{
server.DeleteTree();
server.CommitChanges(); //THROWING ERROR
}
}
}
}
I am also having ADMINISTRATOR rights on machine.I am running some msi in between of deleting and recreating/hosting website in IIS 6.0
View the full article
Environment: Visual Studio 2008/SQL Server 2005
Operating System: Windows Server 2003
I am using below code to Create and Host Website in IIS.
In first time, Website Created and deleted successfully, While Recreating/Hosting Website in IIS 6.0 throws Error in below Line:
object websiteId = (object)w3svc1.Invoke("CreateNewSite", newsite);
Error:
Message = "Exception has been thrown by the target of an invocation."
Inner Exception: InnerException = The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
[System.Reflection.TargetInvocationException] = {"Exception has been thrown by the target of an invocation."}
DirectoryEntry w3svc1 =new DirectoryEntry("IIS://localhost/W3SVC");
//Create a website object array
object[] newsite = newobject[] { "TelnetProbeService",new object[] { "*:90:" }, "c:Test"};
//invoke IIsWebService.CreateNewSite
object websiteId = (object)w3svc1.Invoke("CreateNewSite", newsite);
w3svc1.Properties["ServerAutoStart"][0] = true;
w3svc1.Properties["AuthNTLM"][0] =true;
w3svc1.Properties["AccessScript"][0] =true;
w3svc1.Properties["AccessFlags"][0] = 513;
w3svc1.Properties["AuthAnonymous"][0] =true;
w3svc1.Properties["AccessRead"][0] =true;
w3svc1.Properties["AccessWrite"][0] =false;
w3svc1.Properties["AccessScript"][0] =true;
w3svc1.Properties["AppPoolId"].Value =@"DefaultAppPool";
w3svc1.CommitChanges();
I am using below code to Delete Website in IIS.
DirectoryEntry w3svc =new DirectoryEntry("IIS://localhost/W3SVC","SYNAPSErcatsadmin", "Global@123", AuthenticationTypes.Anonymous);
foreach (DirectoryEntry serverin w3svc.Children)
{
if (server.SchemaClassName == "IIsWebServer")
{
if (server.Properties["ServerComment"][0].ToString() =="TelnetProbeService")
{
server.DeleteTree();
server.CommitChanges(); //THROWING ERROR
}
}
}
}
I am also having ADMINISTRATOR rights on machine.I am running some msi in between of deleting and recreating/hosting website in IIS 6.0
View the full article