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
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