COMException when binding a new System.DirectoryServices.DirectoryEntry object to IIS
Posted on 2005-04-26
I'm experiencing a rather interesting problem using the DirectoryEntry object. Here is the code in question:
System.DirectoryServices.DirectoryEntry iisRoot = new System.DirectoryServices.DirectoryEntry("IIS://" + serverAddress + "/W3SVC/1/Root");
Although I haven't included the rest of the method's code, it should suffice to say I'm just using this DirectoryEntry object to create a new virtual directory. The code seems simple enough, and works perfectly fine when the "serverAddress" parameter is "127.0.0.1" or "localhost" or "192.168.1.100" (my network IP address). However, as soon as I put in "192.168.1.101" (or the address of any other computer, for that matter) the application throws this:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in system.directoryservices.dll
Additional information: The RPC server is unavailable
The odd thing is that the catch block doesn't catch the exception. VS.NET (in debug mode) just throws me that error and breaks the debug run and won't show me any exception related information (InnerException, StackTrace, etc.). So, because of that, I can't drill down at all to see what might be causing the problem at a deeper level.
My dev machine is running: Windows XP Professional (with Service Pack 2), IIS 5, Visual Studio .NET 2003. I'm wondering if it may be an issue with Service Pack 2, but I'm not sure.