Reputation: 170499
I have a COM DLL written in Visual C++. I fully control that COM DLL code. Of course it can be consumed from both managed and unmanaged applications. I want to insert a very specific check that should only be run when the COM DLL is consumed by a .NET application.
Is there some programmatic way for my COM object to detect whether it is being consumed from a .NET application or from an unmanaged application?
Upvotes: 3
Views: 360
Reputation: 174309
Two possibilities:
Upvotes: 1
Reputation: 941455
These kind of "what's my environment" questions always have the same answer. Your host has no trouble figuring out if it is managed, just add a property to your interface to let it tell you. A trivial solution compared with the alternative. Which is impossible to implement reliably in COM, lots of ways to host a server.
Upvotes: 2