Desktop app in store cannot use WinUI3

Michael Chourdakis 66 Reputation points
2023-05-24T22:25:28.8833333+00:00

I 've a mixed app that can use WinUI3 controls or old Win32 controls on demand (configuration or it falls back to Win32 when used in Windows 7 for example).

To use WinUI3, I call the Bootstrap Initialize (https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/win32/mddbootstrap/nf-mddbootstrap-mddbootstrapinitialize2) successfully.

This app is also on the Microsoft store, but when it run as a store app (loading from c:\program files\windowsapps), the call to the bootstrap fails with ERROR_NOT_SUPPORTED.

If I don't call the bootstrap I can't load the WinUI3 classes.

I 've posted a related question in Stack Overflow (https://stackoverflow.com/questions/76301950/store-app-cant-call-mddbootstrapinitialize) which also shows the appxmanifest I use to package with makemsix.

If I take all the files from the store installation directory and put them elsewhere, I can use the bootstrap.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,516 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,960 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Limitless Technology 44,096 Reputation points
    2023-05-25T12:35:41.1133333+00:00

    Hi,

    I'd be happy to help you out with your question. Sorry for the inconvenience caused.

    There are a few possible workarounds:

    You could try using a different method to load the WinUI3 classes. There are a few different ways to do this, and you can find more information in the WinUI3 documentation.

    You could try publishing your app outside of the Microsoft Store. This would allow you to call the Bootstrap Initialize function, but it would also mean that your app would not be available to users who install apps from the Microsoft Store.

    For more Information, please refer to following resource :-

    Tutorial--Use the bootstrapper API in an app packaged with external location or unpackaged that uses the Windows App SDK - https://learn.microsoft.com/windows/apps/windows-app-sdk/tutorial-unpackaged-deployment

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. I'm here to help.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  2. Xiaopo Yang - MSFT 12,151 Reputation points Microsoft Vendor
    2023-05-30T06:39:30.5166667+00:00

    Hello @Michael Chourdakis,

    As this issue is complex, please open an incident via 'Contact us' tab at link below so that our engineer can work with you closely: https://developer.microsoft.com/en-us/windows/support/ and please choose the 'Technical Support - Coding/Debugging' for Windows App SDK for this issue. In-addition, if the support engineer determines that the issue is the result of a bug the service request will be a no-charge case and you won't be charged.


  3. Xiaopo Yang - MSFT 12,151 Reputation points Microsoft Vendor
    2023-06-01T01:35:14.85+00:00

    @Michael Chourdakis

    Apart from your workaround, try the code.


    SelfContained = No bootstrapper support or necessary

     

    But change that to “unpackaged store-deployed app attempting to use the bootstrapper with WinAppSDK__/MSIX”__ then No, it’s not supported. The reason isn’t ACLs; Store doesn’t distribute the DDLM packages (required for Bootstrapper’s magic), and you can’t use WinAppSDK’s Deployment API to workaround that issue because you need access to WinAppSDK to use it (a chicken/egg problem).

     

    You can instead use Windows 11’s Dynamic Dependencies API to accomplish this. In the linked sample’s App.cpp change lines 264-274 to this

    #include <appmodel.h>
    
    int __stdcall WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
    {
           CoInitializeEx(0, COINIT_APARTMENTTHREADED);
    
           PCWSTR packageFamilyName{ WINDOWSAPPSDK_RUNTIME_PACKAGE_FRAMEWORK_PACKAGEFAMILYNAME_W };
           const PACKAGE_VERSION minVersion{};
           const auto architectures{ PackageDependencyProcessorArchitectures_None };
           const auto lifetimeKind{ PackageDependencyLifetimeKind_Process };
           PCWSTR lifetimeArtifact{};
           const auto options{ CreatePackageDependencyOptions_None };
           wil::unique_process_heap_string packageDependencyId;
           RETURN_IF_FAILED(TryCreatePackageDependency(nullptr, packageFamilyName, minVersion, architectures, lifetimeKind, lifetimeArtifact, createOptions, wil::out_param(packageDependencyId)));
           
           const INT32 rank{ PACKAGE_DEPENDENCY_RANK_DEFAULT };
           auto addOptions{ AddPackageDependencyOptions_None };
           RETURN_IF_FAILED(AddPackageDependency(packageDependencyId.get(), rank, addOptions, wil::out_param(packageDependencyContext), wil::out_param(packageFullName)));
    
           auto app3 = make<AppL>();
           Application::Start([&](auto&&) {
                  app3;
                  });
           return 0;
    }
    

    The Win11 API has none of the restrictions of the WinAppSDK implementation. The only caveat is it’s only available on Win11.

    0 comments No comments