Log calls to QueryInterface in managed COM server

367 views Asked by At

I followed the example here to create a C# out-of-process COM server.

My server is used from a third-party application I don't have control over. In order to find out which interfaces they ask for when loading my component, I'd like to log all their calls to the QueryInterface method. However, because I'm using .NET I can't implement IUnknown::QueryInterface on my own - it is instead automatically provided by the CCW (COM callable wrapper).

Is there a way to log all the calls to QueryInterface for my C# COM server?

1

There are 1 answers

0
Daniel Lang On BEST ANSWER

I'm sorry for answering my own question, but after some very research intensive days of work, I found that since .NET 4 one can implement ICustomQueryInterface and provide his own managed implementation of QueryInterface. Adding logging to it will be very easy.