How to fix "HRESULT:0x80070578 Invalid window" exception when calling store service function RequestPurchaseAsync() in a Win32 app packed as MSIX package

Hongkun Wang 20 Reputation points
2025-03-05T03:30:52.17+00:00

I'm packing a Win32 app coded by C++ into a MSIX package and trying to publish at Microsoft app store. My app has in-app products to let users purchase.

The app is coded in classic Win32 API in C++ and the in-app purchase module is coded by Windows Runtime with C++/CX and compiled by "/ZW" (Windows Runtime Compilation) options.

The in-app purchase is done by calling RequestPurchaseAsync().

Since I use desktop bridget to consume Windows Rumtime in Win32 app, I carefully following the following resource to make sure:

your application must configure the StoreContext object to specify which application window is the owner window for modal dialogs that are shown by the object.

https://learn.microsoft.com/en-us/windows/uwp/monetize/in-app-purchases-and-trials#desktop

I have applied all related code (IInitializeWithWindow) in my code by following the sample code in this link:

https://learn.microsoft.com/en-us/answers/questions/2105663/issues-with-requestpurchaseasync-in-mfc-c-applicat

The result I got:

  • if my Win32 app is packed as appContainer app, then RequestPurchaseAsync() crashes with "HRESULT:0x80070578 Invalid window" exception.
  • if Win32 app is packed as full-trust app, then RequestPurchaseAsync() works and the modal dialog shows up to allow user to purchase product.

I use the following attributes in my WAP project (.wapproj) file to make my MSIX package either a container based app or a full-trust app. "Partial" to pack as container app and "Full" to pack as full-trust app. The related resource is at:

https://learn.microsoft.com/en-us/windows/msix/msix-container

<ProjectReference Include="..\MyWin32App.vcxproj">
      <TrustLevel>Partial</TrustLevel>
</ProjectReference>

My Question is:

How can I pack my Win32 app as appContainer app while store service works well without raising "HRESULT:0x80070578 Invalid window" exception?

When a submitted app is being evaluated, a full-trust app needs to provide further explanation about why the app need to use "runFullTrust" permission. That is why I prefer packing my app as container app.

By the, following shows the permissions in Package.appxmanifest file to make app packed as full-trust app:

<Capabilities>
    <Capability Name="internetClient" />
   <rescap:Capability Name="runFullTrust" />
  </Capabilities>

Thanks for any suggestions.

Hongkun Wang

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,741 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jeanine Zhang-MSFT 11,106 Reputation points Microsoft External Staff
    2025-03-05T07:53:24.56+00:00

    Hi

    Welcome to Microsoft Q&A!

    It's hard to say what causes the behavior. According to your description, it seems that the TrustLevel is the cause of this behavior because it works well in full-trust package. It should have some deep mechanism that led to such behavior, but it might out of the scope of the forum support which needs paid support to dig it further.

    Currently, the simple solution we recommend is that you could package your win32 program into a full-trust app and publish it.

    Regarding the explanation about why the app need to use "runFullTrust" permission, you just need to explain that you have packaged the win32 app into an MSIX app and the full-trust capability is necessary.

    Jeanine

    Thank you

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.