What are the advantages of using COM libraries in comparison to native DLLs from .NET.
One reason I see is that I don’t need to define methods signatures for COM libraries (in comparison to P/Invoke’s DllImport). Are there any others?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can create an object model in COM, something that’s not possible with pinvoke. Very similar to .NET classes with methods, properties and events supported. A good example is the Office interop namespaces (like Microsoft.Office.Interop.Excel), implemented in pure COM on the Office side.
Do note that highly usable COM libraries like that use COM Automation, a subset of COM that was designed to make interop between different languages very easy. But it puts severe restrictions on the kind of types you can use in the method declarations.
Writing COM code in C++ is not particularly easy, although ATL and the built-in Visual Studio wizards can help a lot. Do consider using the C++/CLI language instead. Much easier to get going thanks to built-in interop support in the language.