Summary

Team-Fly    

 
.NET and COM Interoperability Handbook, The
By Alan Gordon
Table of Contents
Chapter Seven.  Advanced .NET to COM Interop

Summary

In this chapter, you learned about some of the advanced aspects of COM Interop from the perspective of a .NET client talking to a COM object. You learned about the object life cycle implications of COM Interop, that is, that a COM object when used through COM Interop will behave like a managed object because the RCW will hold a reference to the object until the RCW is garbage collected. If you want to destroy your COM object immediately after its use, you will need to call the ReleaseComObject method on the System.Runtime.InteropServices.Marshal class .

You next learned how COM events map to managed events. You learned that, even though this mapping is difficult to understand, it is trivial to use. I next turned my attention to how COM-rich error information is mapped to managed code exceptions. Then, I turned my attention to multithreading and COM Apartments. You learned that, even though managed code does not use COM Apartments by default, a managed thread will enter an Apartment if you use a COM object. For performance reasons, it is important that you make sure that this Apartment is compatible with the object that you are using. I showed you how to specify what type of Apartment your managed thread should enter. I next talked about primary Interop assemblies. You learned that, if you have created a COM object that you expect to be called from managed code, you should create a primary Interop assembly. By doing this, a client won't generate multiple versions of the Interop assembly for your COM object if the assembly is referenced by several other COM servers. Next I discussed Interop marshaling. You learned how COM Interop marshals strings that are declared by the COM object as something other than BSTR. I than spent a long time discussing arrays. I first talked about marshaling safe arrays, and then I talked about c-style arrays. I then talked about how to use ActiveX controls from managed clients . I then discussed the performance implications of COM Interop. I ended the chapter by discussing some advanced aspects of COM Interop.

In the next chapter, I will look at advanced aspects of COM to .NET Interop, that is, calling a managed code component from a COM/Win32 client.


Team-Fly    
Top
 


. Net and COM Interoperability Handbook
The .NET and COM Interoperability Handbook (Integrated .Net)
ISBN: 013046130X
EAN: 2147483647
Year: 2002
Pages: 119
Authors: Alan Gordon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net