-1

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

So, I'm wondering if it's possible to programmatically open a MAUI application from within a WinForms app?

Thank you for the answers.

  • Does this answer your question? [How do I start a process from C#?](https://stackoverflow.com/questions/181719/how-do-i-start-a-process-from-c) – PMF Jun 22 '23 at 12:46
  • 1
    Whether the other process is MAUI, also Winforms, native or whatever is completely irrelevant here. – PMF Jun 22 '23 at 12:46
  • @PMF, I'm getting Win32Exception (0x80004005) "No application is associated with the specified file for this operation – Gaurav Sharma Jun 22 '23 at 12:53
  • 1
    That won't work if your app is in a package as [Alexandar has already told you](https://stackoverflow.com/a/76528289/16938087). How are you deploying your app? – Dour High Arch Jun 22 '23 at 13:38
  • 1
    @GauravSharma can you post the exception and the code you are running in your question? – H.A.H. Jun 22 '23 at 13:39

1 Answers1

1

The maui proejct on the windows will be packaged by the MSIX Application Packager. You can add the following code below </uap:VisualElements> in the /Platforms/Windows/Package.appxmanifest:

xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
     .....
     .....
</uap:VisualElements>
       <Extensions>
                    <uap5:Extension
                                Category="windows.appExecutionAlias"
                                Executable="MauiAppTest.exe"
                                EntryPoint="Windows.FullTrustApplication">
                          <uap5:AppExecutionAlias>
                                <uap5:ExecutionAlias Alias="MyApp.exe" />
                          </uap5:AppExecutionAlias>
                    </uap5:Extension>
              </Extensions>

And then, you can use the Process.Start("MyApp.exe"); to start the maui app in the WinForms Application.

Liyun Zhang - MSFT
  • 8,271
  • 1
  • 2
  • 14