1

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?

Daniel Lang
  • 6,819
  • 4
  • 28
  • 54
  • can't you place some logging based on the link that you provided..? and write to your own log file..? – MethodMan Aug 03 '12 at 19:43
  • No, because the QueryInterface method is provided automatically by the .NET wrapper (CCW) and I can't implement the corresponding IUnknown interface itself in C# (not allowed). – Daniel Lang Aug 03 '12 at 19:45
  • Look at this link checkout the second answer QueryInterface can be done http://stackoverflow.com/questions/5077172/how-do-i-use-marshal-queryinterface – MethodMan Aug 03 '12 at 19:46
  • I don't want to call QueryInterface myself on another COM object; instead I provide the COM server on which a client calls my QueryInterface implementation. However, because my implementation of IUnknown::QueryInterface is provided automatically by the .NET Interop Framework I can't insert logging there. Thanks anyway – Daniel Lang Aug 03 '12 at 19:55
  • why you want to know that? Is it only for logging purpose? Or the code will have to take some decision based on what interface is requested? – Ankush Aug 03 '12 at 21:04
  • I'm developing an IM provider for MS Outlook and because of the lack of documentation I don't know which interfaces I need to implement. I only see a 0x80004002 error (E_NOINTERFACE) in the Outlook presence log written on startup. – Daniel Lang Aug 03 '12 at 21:18

1 Answers1

1

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.

Daniel Lang
  • 6,819
  • 4
  • 28
  • 54