.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
3.04.2002

 

Runtime Callable Wrappers



Just a couple notes about calling COM objects from managed code. We had some discussions about all this at my latest G.NET brain dump session.




  • Locallay declared runtime callable wrapper object becomes garbage when it goes out of scope.
  • COM object that is being wrapped will be released at the next garbage collection.
  • Force immediate release of RCW's internal COM object with Marshal.ReleaseComObject() [from System.Runtime.InteropServices]



Late-binding a COM object


System.Type ComType = Type.GetTypeFromProgID( "foo.foo.1" );
System.Object ComObj = Activator.CreateInstance( ComType );
ComType.InvokeMember( "MethodNameHere",
Reflection.BindingFlags.InvokeMethod, null,
ComObj, params );



Comments: Post a Comment

Powered by Blogger