How to open MAUI Application from WinForms Application

Gaurav Sharma83 20 Reputation points
2023-06-22T12:27:32.1633333+00:00

I am working on WinForms app which I'm trying to open MAUI application from WinForms application.

So, I am wondering, if it is possible to open MAUI Application from within WinForms app?

Developer technologies Windows Forms
Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-06-23T05:07:29.2233333+00:00

    Hello,

    MAUI app that targets on Windows platform uses WinUI3, and it currently only allows publishing an MSIX package. You could refer to Publish a .NET MAUI app to a folder for Windows - .NET MAUI | Microsoft Learn

    The main question is how to open/launch a WinUI3 published app (MSIX) from WinForms app. You could try to launch the app with an execution alias.

    Please open the source code of /Platforms/Windows/Package.appxmanifest in your MAUI app, then reference the namespace(xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5") in the top of Package.appxmanifest, add add the following code in the Application element.

    <Extensions>
                <uap5:Extension Category="windows.appExecutionAlias">
                    <uap5:AppExecutionAlias>
                        <uap5:ExecutionAlias Alias="MyApp.exe"/>
                    </uap5:AppExecutionAlias>
                </uap5:Extension>
            </Extensions>
    

    After that, you can call Process.Start("MyApp.exe") in your WinForms app.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    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.