Reputation: 563
I want to launch my MAUI windows application via command-line. When I try to do that I am getting this error which freeze launch screen. I did this for Xamarin Forms windows application and it works.
Error
System.Runtime.InteropServices.COMException: 'The application called an interface that was marshalled for a different thread.
The Application Object must initially be accessed from the multi-thread apartment.'
You can create a new MAUI Multi Platform template app and add these to the WinUI project's appxmanifest.
Package.appxmanifest
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
IgnorableNamespaces="uap rescap uap5">
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="MauiApp3"
Description="MauiApp3"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap5:Extension
Executable="MauiApp3.WinUI.exe"
EntryPoint="MauiApp3.WinUI.App"
Category="windows.appExecutionAlias">
<uap5:AppExecutionAlias>
<uap5:ExecutionAlias Alias="maui33.exe" />
</uap5:AppExecutionAlias>
</uap5:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
Upvotes: 0
Views: 102
Reputation: 13899
I could reproduce this problem, and I resolved this problem by replacing the following code:
EntryPoint="MauiApp3.WinUI.App"
with:
EntryPoint="Windows.FullTrustApplication"
Upvotes: 3