2

I need to implement a class in C++ that can call a C# function from unmanaged C++ and return a value. I've done this from C++ to C++ using MIDL/RPC binding over named pipe which works great but now my server application is moving to C# but the client must remain unmanaged C++ (it's an explorer extension).

I've looked at various methods and lots of people suggest COM, it was my understanding that COM was not so much for IPC/RPC but for hosting a served object in a client app. Is this going to be possible with COM, if so, can anyone point me in the direction of a good reference or example?

EDIT:

Just to be clear, I cannot use managed code as the client (DLL) is loaded into Explorer's process space.

What I am trying to achieve is when the user right-clicks on a file the extension will ask a running service (session 0) for some details about the file. This was previously done via RPC in a C++ <-> C++ client/server. Now the server has been upgraded to C# but I'm not sure what my options are. Is COM an option?

Thanks, J

2
  • 1
    COM uses RPC when necessary, in out-of-process or cross-apartment cases. Not having to wrangle RPC is of course very nice. There are not enough details in your question to even tell if this applies. Commented Oct 19, 2011 at 12:26
  • Edited to include some more details. Commented Oct 19, 2011 at 13:05

1 Answer 1

2

Use mixed CLR and native C++ DLL. Check MSDN and tools.

Native and .NET Interoperability

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

8 Comments

I can't use the CLR in my extension as it is loaded into the Explorer process space. blogs.msdn.com/b/junfeng/archive/2005/11/18/494572.aspx
@JWood: What do you want to use from .net? Own module?
I need to call a function in a running C# service to retrieve information about a file when the user right-clicks in Explorer. WCF achieves this nicely via named pipes but how can unmanaged C++ call a function in a running C# service?
@JWood: for IPC I usually use TCP/IP and XML. They are future proof and system independent.
It doesn't need to be system independent, this is Windows only and there is a lot of overhead involved with building TPC/IP and XML libraries into an Explorer extension. This was going to be my last resort but with COM being suggested often I wanted to explore the possibility.
|

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.