System.Runtime.InteropServices.COMException: Unknown error (0x80005000)

  • Thread starter Thread starter Andrew Raastad
  • Start date Start date
A

Andrew Raastad

I have been trying to find an answer to my problem, and the closest so far I
could find was this post:
http://social.msdn.microsoft.com/Forums/en/netfx64bit/thread/6078be16-0d1a-4d6a-81f3-09418ac94c34

However, while we're getting the same error, mine stems from something a
little different... I think.

I have a VB.Net app that uses Directory Services to create several Virtual
Directories in IIS. This app work perfectly, without error or exception of
any kind on 32bit machines (XP, Vista, Server2003, Server2008, etc.) running
IIS5/6/7. However, when I run the app (making no code changes) on our first
64bit test machine, a Win Server 2008 R2 64bit with IIS7.5, it throws a
"System.Runtime.InteropServices.COMException" exception.

The method executed when the exception is thrown (the "If
DirectoryEntry.Exists()..." line is what I believe is throwing the
exception):

Public Sub CreateVirtualDirectory(ByVal IISPath As String, ByVal
PhysicalPath As String, ByVal FolderName As String, ByVal AccessRead As
Boolean, ByVal AccessWrite As Boolean, ByVal AccessSource As Boolean, ByVal
AccessScript As Boolean, ByVal AccessExecute As Boolean, Optional ByVal
SetAsApplication As Boolean = False)
Try
Dim Parent As New DirectoryEntry(IISPath)
Dim NewVirtualDirectory As DirectoryEntry

' Remove the directory if it exists
If DirectoryEntry.Exists(IISPath & "/" & FolderName) Then
Dim parms As Object() = {"IIsWebVirtualDir", FolderName}
Parent.Invoke("Delete", parms)
End If

' Create the virtual directory with specified settings
NewVirtualDirectory = Parent.Children.Add(FolderName,
"IIsWebVirtualDir")
With NewVirtualDirectory
If SetAsApplication Then
.Invoke("AppCreate2", 2)
.Properties("AppFriendlyName")(0) = FolderName
End If
.Properties("Path")(0) = PhysicalPath
.Properties("AccessScript")(0) = AccessScript
.Properties("AccessSource")(0) = AccessSource
.Properties("AccessRead")(0) = AccessRead
.Properties("AccessWrite")(0) = AccessWrite
.Properties("AccessExecute")(0) = AccessExecute
.CommitChanges()
'If SetAsApplication Then
'End If
End With

Catch ex As Exception
Throw New Exception("CreateVirtualDirectory() Failed:" &
vbCrLf & ex.ToString)

End Try
End Sub


And this is the exception:

System.Exception: CreateVirtualDirectory() Failed:
System.Runtime.InteropServices.COMException (0x80005000): Unknown error
(0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Exists(String path)


This code works fine on every other (32bit) machine we've tested, but now
bombs on a 64bit. What's the problem here?

-- Andrew
 
For those playing the home version....

I was pointed to the following blog post:
http://blogs.msdn.com/jpsanders/arc...tion-0x80005000-unknown-error-0x80005000.aspx

This was exactly the info I needed. The answer lay in the piece:

"IIS 7 does not install an ADSI provider by default. You can enable it
however as a Role Service for the IIS Web Server. You need to enable the
IIS 6 Metabase Compatiblity role service."

It wasn't until I looked closer at the new Server 2008 64bit box that I saw
the IIS6 stuff had not been installed -- I didn't load the box. Then I went
back and looked at our other 32bit boxes running IIS7 and they *did* have
all the IIS6 stuff installed.

But then we faced the issue of how to determine if this component was
installed or not, as our app could be run on a box thay may or may not have
it ... and apparently it is needed.

So, a little bit of searching around and I was able to locate this article
which seems to have answered that question as well:
http://learn.iis.net/page.aspx/135/discover-installed-components/

I hope this helps anyone out there facing the same problems I had.

-- Andrew
 
Back
Top