When running MAUI app in .net 9 in debug it works but without debugging is not

Dani_S 4,036 Reputation points
2025-02-02T06:29:57.61+00:00

Hi,

I moved from maui app in .NET 8 to .NET 9.

The project build but n debug it works but without debugging the login page is not opened.

I checked all nugets packages and moved to last.

================================

<ItemGroup>

<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />

<PackageReference Include="CommunityToolkit.Maui" Version="9.0.0" />

<PackageReference Include="System.Management" Version="9.0.1" />

<PackageReference Include="Telerik.UI.for.Maui" Version="8.0.0" />

<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />

<PackageReference Include="Autofac" Version="8.2.0" />

<PackageReference Include="DotNetZip" Version="1.16.0" />

</ItemGroup>

<!-- Windows -->

<ItemGroup Condition="$(TargetFramework.Contains('-windows')) == true">

<PackageReference Include="WindowsAPICodePack" Version="8.0.6" />

</ItemGroup>

This is my xaml.cs

===========

public partial class App : Application

{

private static Mutex mutex = new Mutex(true, Assembly.GetEntryAssembly().GetName().Name);

public App()

{

if (!mutex.WaitOne(TimeSpan.Zero, true))

{

Current.Quit();

Environment.Exit(0);

}

InitializeComponent();

MainPage = new LoginPage();

}

protected override Window CreateWindow(IActivationState? activationState)

{

Window window = base.CreateWindow(activationState);

try

{

window.Stopped += async(s,e) =>

{

if (!string.IsNullOrEmpty(LoginConfigurations.GetInstance().SessionToken ))

{

var container = new Bootstrapper().Bootstrap();

IAutomationApiClient automationApiClient = container.Resolve<IAutomationApiClient>();

var results = await automationApiClient.PostLogOut($"{LoginConfigurations.GetInstance().Portal}/api/GSPortal/PostLogOut/false", LoginConfigurations.GetInstance().SessionToken);

if(results)

{

App.Current.Quit();

}

}

};

}

catch (Exception)

{

}

return window;

}

}

}

  1. I comment the mutex code + CreateWindow same problem.

How to solve the problem ?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,882 questions
0 comments No comments
{count} votes

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.