all groups > dotnet interop > march 2005 >
You're in the

dotnet interop

group:

ReleaseComObject and CoLockObjectExternal



ReleaseComObject and CoLockObjectExternal Clive Dixon
3/11/2005 12:20:34 PM
dotnet interop: I have .NET client code essentially doing the following interop, getting
hold of an application's automation interface which has been registered in
the ROT, and the application's object has been locked using
CoLockObjectExternal:

ApplicationClass app = new ApplicationClass();

// Do something with app

Marshal.ReleaseComObject(app);

app = null;

However I find that even though the application's reference count was
incremented by 3 on getting the object, on releasing the RCW the reference
count does NOT decrease. When later the application calls
CoLockObjectExternal on the object, all those 3 references get released all
at once along with the original reference added by the initial
CoLockObjectExternal lock. What is going on here and why is it behaving like
this?



Re: ReleaseComObject and CoLockObjectExternal Clive Dixon
3/11/2005 1:10:07 PM
Sorry, should clarify with
"When later the application calls CoLockObjectExternal on the object **to
release the external reference**..."

[quoted text, click to view]

AddThis Social Bookmark Button