Using Visual Studio 2005, C#, trying to create Virtual Directory on Windows Vista Enterprise.
The following function is called from the Installer and should create a virtual directory on the user's local machine.
All the code works perfectly on Windows XP Pro.
My C# Code:
public void CreateVirtualDirectory(string physicalPath, string VDName)
{
//Create a virtual directory
const int MD_AUTH_NT = 0x00000004; //Windows authentication schemes available.
const int MD_AUTH_ANONYMOUS = 0x00000001; //Anonymous authentication available.
System.EnterpriseServices.Internal.IISVirtualRoot vr = new System.EnterpriseServices.Internal.IISVirtualRoot();
string sError = "";
vr.Create("IIS://localhost/W3SVC/1/Root", physicalPath, VDName, out sError);
if (sError.Trim().Length > 0)
{
throw new Exception("Error when creating Virtual Directory:" + Environment.NewLine + sError);
}
DirectoryEntry deVDir = new DirectoryEntry("IIS://localhost/W3SVC/1/Root/" + VDName);
if (deVDir != null)
{
deVDir.Properties["AuthFlags"].Value = MD_AUTH_NT; //MD_AUTH_ANONYMOUS |
deVDir.CommitChanges();
}
else
{
throw new Exception("Error when creating Virtual Directory:" + Environment.NewLine + "Could not find VD " + VDName);
}
}
The above code throws the error:
(caused by line: vr.Create("IIS://localhost/W3SVC/1/Root", physicalPath, VDName, out sError); )
Log Name: Application
Source: MsiInstaller
Date: 2007/07/30 03:33:36 PM
Event ID: 11001
Task Category: None
Level: Error
Keywords: Classic
User: SOFTCRAFT\moutono
Computer: VISTAPC.softcraft.co.za
Description:
The description for Event ID 11001 from source MsiInstaller cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Product: Rivers -- Error 1001. Error 1001: Error when creating Virtual Directory:
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.CheckIsContainer()
at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)
at System.EnterpriseServices.Internal.IISVirtualRoot.Create(String RootWeb, String inPhysicalDirectory, String VirtualDirectory, String& Error)
(NULL)
(NULL)
(NULL)
(NULL)
the message resource is present but the message is not found in the string/message table
I too am trying to create a virtual directory using c# in Vista. I've tried the above code and it seems to run fine but no virtual directory is ever created.
Are you expecting it to actually create a physical folder? The code above only creates the metabase entry for the virtual directory. Are you not seeing it when you run:
> %windir%\system32\inetsrv\appcmd list vdirs
This code will require you to install the metabase compatibility as I mentioned above.
Thanks,
Mike Volodarsky
Program Manager
IIS Core Server
Visit mvolo.com for more inside information on IIS7, IIS and ASP.NET
Mike Volodarsky
CTO at LeanSentry
Former IIS/ASP.NET PM
Want to become an expert at monitoring and troubleshooting your IIS applications?
See the demo at www.leansentry.com!
can i define a new virtual directory in by the appcmd,
and define also the defualt document to load?
<div>and also i would like to know how can i discuver if </div> <div>Internet Information Services>Web Management Tools>IIS 6 Management Compatibility>IIS Metabase and IIS 6 configuration compatibility</div> <div> </div> <div>is installed?(from registry maby?)</div>
this code deletes the virtual directory in 32
bit
system on win2k3 but not on win2k3 64 bit system.
can anybody help me resolve this issue.
Exception i am getting is :
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_Schema ClassName()
at NetIQ.NQACService.ACServiceInstaller.DeleteVirtual Directory(String rootWeb, String virtualDirName)
this code deletes the virtual directory in 32
bit
system on win2k3 but not on win2k3 64 bit system.
can anybody help me resolve this issue.
Exception i am getting is :
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_Schema ClassName()
at NetIQ.NQACService.ACServiceInstaller.DeleteVirtual Directory(String rootWeb, String virtualDirName)
I'm facing the same issue. My component was working fine under IIS 7.0 recently we've migrated to .NET 4.0 and we are getting the "Unknown error (0x80005000)" while performing IIS operations using Directory Services.
Tom10
1 Post
Creating IIS 7 Virtual Directory with C# code
Jul 30, 2007 03:33 PM|LINK
Hi,
Using Visual Studio 2005, C#, trying to create Virtual Directory on Windows Vista Enterprise.
The following function is called from the Installer and should create a virtual directory on the user's local machine.
All the code works perfectly on Windows XP Pro.
My C# Code:
public void CreateVirtualDirectory(string physicalPath, string VDName)
{
//Create a virtual directory
const int MD_AUTH_NT = 0x00000004; //Windows authentication schemes available.
const int MD_AUTH_ANONYMOUS = 0x00000001; //Anonymous authentication available.
System.EnterpriseServices.Internal.IISVirtualRoot vr = new System.EnterpriseServices.Internal.IISVirtualRoot();
string sError = "";
vr.Create("IIS://localhost/W3SVC/1/Root", physicalPath, VDName, out sError);
if (sError.Trim().Length > 0)
{
throw new Exception("Error when creating Virtual Directory:" + Environment.NewLine + sError);
}
DirectoryEntry deVDir = new DirectoryEntry("IIS://localhost/W3SVC/1/Root/" + VDName);
if (deVDir != null)
{
deVDir.Properties["AuthFlags"].Value = MD_AUTH_NT; //MD_AUTH_ANONYMOUS |
deVDir.CommitChanges();
}
else
{
throw new Exception("Error when creating Virtual Directory:" + Environment.NewLine + "Could not find VD " + VDName);
}
}
The above code throws the error:
(caused by line: vr.Create("IIS://localhost/W3SVC/1/Root", physicalPath, VDName, out sError); )
Log Name: Application
Source: MsiInstaller
Date: 2007/07/30 03:33:36 PM
Event ID: 11001
Task Category: None
Level: Error
Keywords: Classic
User: SOFTCRAFT\moutono
Computer: VISTAPC.softcraft.co.za
Description:
The description for Event ID 11001 from source MsiInstaller cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Product: Rivers -- Error 1001. Error 1001: Error when creating Virtual Directory:
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.CheckIsContainer()
at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)
at System.EnterpriseServices.Internal.IISVirtualRoot.Create(String RootWeb, String inPhysicalDirectory, String VirtualDirectory, String& Error)
(NULL)
(NULL)
(NULL)
(NULL)
the message resource is present but the message is not found in the string/message table
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="MsiInstaller" />
<EventID Qualifiers="0">11001</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2007-07-30T13:33:36.000Z" />
<EventRecordID>1479</EventRecordID>
<Channel>Application</Channel>
<Computer>VISTAPC.softcraft.co.za</Computer>
<Security UserID="S-1-5-21-4206377478-2519145661-2763947379-1251" />
</System>
<EventData>
<Data>Product: Rivers -- Error 1001. Error 1001: Error when creating Virtual Directory:
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_IsContainer()
at System.DirectoryServices.DirectoryEntries.CheckIsContainer()
at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)
at System.EnterpriseServices.Internal.IISVirtualRoot.Create(String RootWeb, String inPhysicalDirectory, String VirtualDirectory, String& Error)</Data>
<Data>(NULL)</Data>
<Data>(NULL)</Data>
<Data>(NULL)</Data>
<Data>(NULL)</Data>
<Data>
</Data>
<Data>
</Data>
<Binary>7B33324344464143312D303637302D343939452D394343322D3837463635444435353339367D</Binary>
</EventData>
</Event>
Please help!
mvolo
629 Posts
Re: Creating IIS 7 Virtual Directory with C# code
Jul 30, 2007 08:49 PM|LINK
Tom,
Be sure to install the IIS6 Metabase compatibility component of IIS setup to be able to use legacy configuration interfaces like ADSI.
If you are still having trouble, let us know.
Thanks,
Mike Volodarsky
Program Manager
IIS Core Server
Visit mvolo.com for more inside information on IIS7, IIS and ASP.NET
CTO at LeanSentry
Former IIS/ASP.NET PM
Want to become an expert at monitoring and troubleshooting your IIS applications?
See the demo at www.leansentry.com!
valenz4
1 Post
Re: Creating IIS 7 Virtual Directory with C# code
Aug 13, 2007 01:41 PM|LINK
I too am trying to create a virtual directory using c# in Vista. I've tried the above code and it seems to run fine but no virtual directory is ever created.
Some one please help!!!
mvolo
629 Posts
Re: Creating IIS 7 Virtual Directory with C# code
Aug 13, 2007 05:14 PM|LINK
Are you expecting it to actually create a physical folder? The code above only creates the metabase entry for the virtual directory. Are you not seeing it when you run:
> %windir%\system32\inetsrv\appcmd list vdirs
This code will require you to install the metabase compatibility as I mentioned above.
Thanks,
Mike Volodarsky
Program Manager
IIS Core Server
Visit mvolo.com for more inside information on IIS7, IIS and ASP.NET
CTO at LeanSentry
Former IIS/ASP.NET PM
Want to become an expert at monitoring and troubleshooting your IIS applications?
See the demo at www.leansentry.com!
yaniv101
2 Posts
Re: Creating IIS 7 Virtual Directory with C# code
Jun 02, 2008 01:39 PM|LINK
Hi there
can i define a new virtual directory in by the appcmd,
and define also the defualt document to load?
<div>and also i would like to know how can i discuver if </div> <div>Internet Information Services>Web Management Tools>IIS 6 Management Compatibility>IIS Metabase and IIS 6 configuration compatibility</div> <div> </div> <div>is installed?(from registry maby?)</div>bills
433 Posts
Microsoft
Re: Creating IIS 7 Virtual Directory with C# code
Jun 03, 2008 12:55 AM|LINK
Creating a virtual directory: http://technet2.microsoft.com/windowsserver2008/en/library/87d8a3d7-8d90-4626-8f85-3c782ec9a5331033.mspx?mfr=true
Defining a default document: http://technet2.microsoft.com/windowsserver2008/en/library/45297f77-f6c0-48da-89ee-0c378bac8e051033.mspx
Discovering which IIS7 components are installed: http://learn.iis.net/page.aspx/135/discover-installed-components/
Bill Staples
Product Unit Manager, IIS
blog: http://blogs.iis.net/bills
yaniv101
2 Posts
Re: Creating IIS 7 Virtual Directory with C# code
Jun 03, 2008 07:28 AM|LINK
hems4all
2 Posts
Re: Deleting IIS 6 Virtual Directory with C# code
Dec 04, 2008 09:42 AM|LINK
Hi i have written the code to delete the virtual directory,
Note : i want to delete virtual directory from IIS console also.
this.Message("Delete Virtual Directory.");
DirectoryEntry root = new DirectoryEntry(rootWeb);
DirectoryEntry virtualDir = root.Children.Find(virtualDirName); root.Children.Remove(virtualDir);
root.CommitChanges();
root.Close();
this code deletes the virtual directory in 32 bit system on win2k3 but not on win2k3 64 bit system.
can anybody help me resolve this issue.
Exception i am getting is :
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_Schema ClassName()
at NetIQ.NQACService.ACServiceInstaller.DeleteVirtual Directory(String rootWeb, String virtualDirName)
if anybody reply it ASAP, will be great help.
hems4all
2 Posts
Re: Deleting IIS 6 Virtual Directory with C# code
Dec 04, 2008 09:42 AM|LINK
Hi i have written the code to delete the virtual directory,
Note : i want to delete virtual directory from IIS console also.
this.Message("Delete Virtual Directory.");
DirectoryEntry root = new DirectoryEntry(rootWeb);
DirectoryEntry virtualDir = root.Children.Find(virtualDirName); root.Children.Remove(virtualDir);
root.CommitChanges();
root.Close();
this code deletes the virtual directory in 32 bit system on win2k3 but not on win2k3 64 bit system.
can anybody help me resolve this issue.
Exception i am getting is :
System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boole an throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_Schema ClassName()
at NetIQ.NQACService.ACServiceInstaller.DeleteVirtual Directory(String rootWeb, String virtualDirName)
AB1122
4 Posts
Re: Creating IIS 7 Virtual Directory with C# code
Mar 25, 2010 11:32 AM|LINK
Hi
I'm facing the same issue. My component was working fine under IIS 7.0 recently we've migrated to .NET 4.0 and we are getting the "Unknown error (0x80005000)" while performing IIS operations using Directory Services.
can any one help?
Thanks