T
Tommy Vercetti
I have a very simple COM object that I want to use within .NET. The COM
object was written in C++/ATL. The object works but the problem is the
COM object never seems to be released and the DLL files can never be
overwritten without restarting the computer.
MyLibrary.CMyCOMClass netWrappedCOMObj = new MyLibrary.CMyCOMClassClass();
try {
// Currently, not using the object, just create/dispose
} finally {
System.IntPtr unknownInterface =
Marshal.GetIUnknownForObject(netWrappedCOMObj);
while
(System.Runtime.InteropServices.Marshal.Release(unknownInterface) > 0);
while
(System.Runtime.InteropServices.Marshal.ReleaseComObject(netWrappedCOMObj)
GC.Collect();
GC.WaitForPendingFinalizers();
// I set a breakpoint here and I can't overwrite the COM DLL file. Why
not?
bool debug = true;
}
object was written in C++/ATL. The object works but the problem is the
COM object never seems to be released and the DLL files can never be
overwritten without restarting the computer.
MyLibrary.CMyCOMClass netWrappedCOMObj = new MyLibrary.CMyCOMClassClass();
try {
// Currently, not using the object, just create/dispose
} finally {
System.IntPtr unknownInterface =
Marshal.GetIUnknownForObject(netWrappedCOMObj);
while
(System.Runtime.InteropServices.Marshal.Release(unknownInterface) > 0);
while
(System.Runtime.InteropServices.Marshal.ReleaseComObject(netWrappedCOMObj)
netWrappedCOMObj = null;
GC.Collect();
GC.WaitForPendingFinalizers();
// I set a breakpoint here and I can't overwrite the COM DLL file. Why
not?
bool debug = true;
}