Reputation: 25282
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?
Upvotes: 3
Views: 1566
Reputation: 941208
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.
Upvotes: 4
Reputation: 4215
If you mean differences from COM DLL and native (unmanaged) DLLs from the interop point of view I'd say that COM Servers (DLL/EXE) maps more naturally to the .Net code style (I mean, they look like objects in the .Net world).
From the point of view of the developer (which need to decide whenever go with COM or native "raw" dlls) I'd say that COM allows you to have better functionality grouping (interfaces) (of course COM has more to offer - for instance, properties, events, etc.
Just my 0,02 ;)
Best
Upvotes: 1