J
Jason Kendall
I'm writing a little app to search a computer for all revisions of a
COM object and clean them up. All I'm requiring from the user is the
ProgID of one public class in the library.
The app works great but I want to make make sure that the ProgID
entered is valid, so I wrote a simple function to make sure that this
object can be instantiated (code below).
The problem is that I cannot delete the DLL if I use this test because
I get the following error:
Access to the path "C:\WINDOWS\Downloaded Program
Files\CONFLICT.15\ClientUtilities.dll" is denied.
However, if I do not test and simple run the process, then I can
remove the DLL and, in this case, the 'Conflict.15' folder too.
This leads be to believe that the COM object is not being properly
released so that the DLL can be unloaded from memory and, therefore,
the DLL is locked when I try to delete it.
Any ideas?
Public Function TestCOMObject(ByVal ProgID As String) As Boolean
Try
Dim lcTest As Object
Dim TheType As Type
TheType = Type.GetTypeFromProgID(ProgID, True)
lcTest = CreateObject(ProgID)
If Not IsNothing(lcTest) Then
If (TheType.IsCOMObject) Then
Do While
(System.Runtime.InteropServices.Marshal.ReleaseComObject(lcTest) > 0)
Loop
End If
End If
lcTest = Nothing
Return True
Catch ex As Exception
Return False
Finally
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Function
COM object and clean them up. All I'm requiring from the user is the
ProgID of one public class in the library.
The app works great but I want to make make sure that the ProgID
entered is valid, so I wrote a simple function to make sure that this
object can be instantiated (code below).
The problem is that I cannot delete the DLL if I use this test because
I get the following error:
Access to the path "C:\WINDOWS\Downloaded Program
Files\CONFLICT.15\ClientUtilities.dll" is denied.
However, if I do not test and simple run the process, then I can
remove the DLL and, in this case, the 'Conflict.15' folder too.
This leads be to believe that the COM object is not being properly
released so that the DLL can be unloaded from memory and, therefore,
the DLL is locked when I try to delete it.
Any ideas?
Public Function TestCOMObject(ByVal ProgID As String) As Boolean
Try
Dim lcTest As Object
Dim TheType As Type
TheType = Type.GetTypeFromProgID(ProgID, True)
lcTest = CreateObject(ProgID)
If Not IsNothing(lcTest) Then
If (TheType.IsCOMObject) Then
Do While
(System.Runtime.InteropServices.Marshal.ReleaseComObject(lcTest) > 0)
Loop
End If
End If
lcTest = Nothing
Return True
Catch ex As Exception
Return False
Finally
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Function