Can a .NET component be used from a COM component?
3 Answers
Yes, it's possible.
As thoroughly explained in this CodeProject article, there are two ways to do it:
Early binding, which involves using a tool (Type library Importer, or tlbimp.exe) to create a binary file (a .NET assembly) which contains metadata necessary for the CLR to instantiate the Runtime Callable Wrapper for the COM object. This provides all the strong typing benefits, because you can reference the generated assembly and use these classes like any other .NET classes in your code.
Late binding, which uses the
Type.InvokeMember
method to invoke methods of a COM object by their name, during runtime. Since this approach is weakly typed, it's more error prone than early binding, but it also allows greater flexibility.
Yes, you can do it (like mentioned in the other answers).
It basically boils down to exposing your .NET component as a COM component (this can be done by signing your assembly and just flipping a switch [Make assembly COM-Visible] in the Assembly Information Dialog Box, but good practice demands to implement an interface, and expose only the interface using the ComVisibleAttribute).
This way, your COM component can talk to the .NET component as if it is also a COM component.