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

Dani_S 4,296 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.
4,030 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Bruce (SqlWork.com) 73,001 Reputation points
    2025-02-03T17:52:58.86+00:00

    typically this is caused by using a library that does not support AOT (uses reflection, etc):

    https://learn.microsoft.com/en-us/dotnet/maui/deployment/nativeaot?view=net-maui-9.0

    you can disable AOT. (I'd suspect autofac, and replace it with Services).

    https://github.com/abpframework/abp/issues/21019


  3. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 81,016 Reputation points Microsoft External Staff
    2025-02-13T06:29:21.5266667+00:00

    Hello,

    From Dani_S,

    This issue caused by the <telerik:RadButton> as Password Button, if remove it, this issue is solved.

     <telerik:RadButton x:Name="passwordButton"  Command="{Binding PasswordCommand}" BackgroundImage="White" BorderThickness="0" HorizontalContentAlignment="Start" VerticalOptions="Center" Style="{StaticResource radButton}" WidthRequest="70" HeightRequest="40" Margin="-10,0,0,0"/>
    
    

    Best Regards,

    Leon Lu


    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.

    0 comments No comments

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.