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?

6
  • can't you place some logging based on the link that you provided..? and write to your own log file..? Commented Aug 3, 2012 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). Commented Aug 3, 2012 at 19:45
  • Look at this link checkout the second answer QueryInterface can be done stackoverflow.com/questions/5077172/… Commented Aug 3, 2012 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 Commented Aug 3, 2012 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? Commented Aug 3, 2012 at 21:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.