Out-of-process Classic COM EXE using Windows Runtime Template Library (WRL)
Asked Answered
I

1

6

I have followed the example here: http://msdn.microsoft.com/en-us/library/vstudio/jj822931.aspx to create an In-proc Classic COM DLL using Windows Runtime Template Library (WRL). I am also able to modify to code to run the DLL as COM surrogate (wrapped inside DllHost.exe).

However, I couldn't find the way to create an out-of-process COM EXE using the WRL. There is a simple example using barebone COM API here: http://www.codeproject.com/Articles/3173/A-simple-yet-debuggable-COM-skeleton-code, but I'd like to know how I can utilize WRL to simplify that.

Thanks.

Ingurgitate answered 8/10, 2013 at 6:49 Comment(5)
What's wrong with COM surrogate?Hypothyroidism
There is nothing wrong with the COM surrogate. I am just curious how to implement out-of-proc COM EXE using WRL.Ingurgitate
Out of process COM is so dang painful, it's one of the reasons WCF was invented.Tow
And WCF is another headache :) #13029217Ingurgitate
@Ingurgitate Yes it is! But I argue that WCF is the lesser of two headaches ;-)Tow
S
4

Yes it is possible. I just got one working. Here's the basics that are required, as compared to implementing an in-proc coclass.

  • Implement your coclass using WRL::RuntimeClass the same way you would for an in-proc class. (https://msdn.microsoft.com/en-us/library/jj822931.aspx)
  • In your main function, create a module object using WRL::Module<OutOfProc>::Create(), and call module.RegisterObjects() on startup, and module.UnregisterObjects() and module.Terminate() on shutdown.
  • You need to build a DLL to host the proxies: https://msdn.microsoft.com/en-us/library/windows/desktop/ms688707(v=vs.85).aspx
  • Static Registrations: DO register the Interface and the CLSID of your proxy stub. DO NOT statically register your coclass.
  • In the Client, when you call CoCreateInstance, be sure to use the appropriate CLSCTX. (I use CLSCTX_ALL when the hosting model is not important to the client.)

(I know it's been almost 4 years, but I had the same question this week.)

Superman answered 7/6, 2017 at 22:47 Comment(1)
Thanks, will confirm that the next time I need to fight with COM again :)Ingurgitate

© 2022 - 2024 — McMap. All rights reserved.