Transition from 8 to 9 in maui not worked

Dani_S 4,071 Reputation points
2025-02-05T10:19:41.5433333+00:00

Hi,

Target: move maui app from .net 8 to .net 9 in Mac.

Documentation:

https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0#upgrade-from-net-8-to-net-9

Problem:App not working without debugging.

Steps:

  1. I did all steps in documentation.
  2. Update Nuget packages.
  3. My final Nuget packages in cs proj is:
  4. <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="9.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>
  5. Still problem exist , why ?

In debug that it working I got this error:

Exception has occurred: CLR/System.InvalidOperationException
An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.MacCatalyst.dll: 'Window was already destroyed'
at UIKit.UIApplication.xamarin_UIApplicationMain(Int32 argc, IntPtr argv, IntPtr principalClassName, IntPtr delegateClassName, IntPtr* gchandle)
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at GoodDesktopClient.Maui.Program.Main(String[] args) in
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,900 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 70,776 Reputation points
    2025-02-05T23:45:18.8933333+00:00

    I would suspect it is something in the AppDelegate that is causing the error. in your project file you might set

    <IsAotCompatible>true</IsAotCompatible>

    this will enable aot in the debug build, and may help.

    note: I can build and run a MacCatalyst app from the comandline, but not from vscode debug (AOT error). probably need a workload update.

    this complexity is why I use Xcode/SwiftUI for production applications.


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.