0

My question is whether there are certain limitations to accessing COM objects when you're dealing with an MSIX-packaged app.

I've created a blank WinUI 3 C++ project, using the Visual Studio project template. In the project, I've created a traditional COM class that's registered at runtime using CoRegisterClassObject. I do not otherwise register the object in the registry. It's a singleton that's supposed to be accessible only when the .exe is already launched.

Now when I modify the project to be unpackaged, and the .exe is launched, I'm able to access the singeton class from another process, by calling CoCreateInstance. Everything works as designed.

But when I change the MSIX project back to the packaged setup, the call to CoCreateInstance from the unpackaged process now fails, with code REGDB_E_CLASSNOTREG.

It's like trying to connect to a COM object when there's an unelevated/elevated mismatch. Same error.

So are unpackaged processes unable to access COM objects registered with CoRegisterClassObject in MSIX-packaged apps? Is there a workaround or anything? Thanks in advance.

  • 1
    I'm guessing that packaged apps are sandboxed, placing them outside of the COM ecosystem. The modern equivalent for COM is Windows Runtime (WinRT) Components, which I expect to work when packaged with MSIX. – Paul Dempsey Feb 19 '23 at 02:12
  • Indeed packaged app are sandboxed, so the registry and files are virtualized. WinRT is "just" an extension to COM it will exhibit the same behavior. What you want to do is add your extensions (https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions) to your app package manifest, similar to this https://github.com/microsoft/AppModelSamples/blob/master/Samples/SparsePackages/PhotoStoreDemoPkg/AppxManifest.xml but using the proper Xml element, like com3:ExeServer https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-com3-exeserver – Simon Mourier Feb 19 '23 at 07:58
  • Will that solve the problem with objects registered at runtime using `CoRegisterClassObject`, or does that just solve issues with classes traditionally registered in the registry? –  Feb 19 '23 at 14:07
  • Hitting this problem too unfortunately :( – Charles Milette Mar 23 '23 at 23:10
  • But the other way around - my MSIX packaged app cannot CoCreateInstance a class that has been CoRegisterClassObject'd by an unpackaged process. Works if I make the app unpackaged. – Charles Milette Mar 23 '23 at 23:21

0 Answers0