I don't understand why i get an InvalidCastException when calling
Marshall:ReleaseComObject() in this code :
RCW -----> CCW ----> .NET Control
p1 p2 p3
void Proc( IUnknown* p2 )
{
Object* p1 = Marshal::GetObjectForIUnknown(p2); // p2 is a CCW on a
.NET Control
try
{
.....
}
__finally
{
Marshal::ReleaseComObject(p1); //InvalidCastException here
}
}
Remark : There is no exception if p2 is a normal COM object (not a CCW on a
.NET Control)
Mattias Sj?gren - 17 Jun 2004 12:30 GMT
Try to check if it's an actual COM object with Marshal::IsComObject()
before calling ReleaseComObject().
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.