Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppDomain.CurrentDomain.ProcessExit is not called on macOS (maccatalyst) in MAUI app #78911

Open
MartyIX opened this issue Nov 28, 2022 · 4 comments
Milestone

Comments

@MartyIX
Copy link
Contributor

MartyIX commented Nov 28, 2022

Description

I have tried to register the AppDomain.CurrentDomain.ProcessExit event in my MAUI app running on macOS (maccatalyst) but the event is not fired. However, when the same app is run on Windows, the event is fired.

Filed also as: dotnet/maui#11676, @rolfbjarne suggested that this might be a dotnet/runtime repo so I took the opportunity to file the issue here. I'm sorry if this is not correct place. Feel free to close the issue if it does not belong here.

Reproduction Steps

Modify a sample MAUI app as follows:

using System;

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new AppShell();

        AppDomain.CurrentDomain.ProcessExit += this.OnProcessExit; // Added line.
    }

    // This method is not called on macOS but it is called on Windows.
    private void OnProcessExit(object sender, EventArgs e)
    {
        throw new Exception("REACHED?");
    }
}

Expected behavior

I expect OnProcessExit to be called.

Actual behavior

OnProcessExit method is NOT called.

Interestingly though, in a standard .NET console app on macOS (i.e net7.0), CurrentDomain_ProcessExit is called:

public static class Program
{
    public static void Main(string[] args)
    {
        AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
    }

    private static void CurrentDomain_ProcessExit(object? sender, EventArgs e)
    {
        throw new NotImplementedException();
    }
}

So the issue seems to be MAUI specific.

Regression?

No response

Known Workarounds

I have not found any.

Configuration

macOS M1, .NET 7 (i.e. latest released version)

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Nov 29, 2022

Tagging subscribers to 'os-maccatalyst': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I have tried to register the AppDomain.CurrentDomain.ProcessExit event in my MAUI app running on macOS (maccatalyst) but the event is not fired. However, when the same app is run on Windows, the event is fired.

Filed also as: dotnet/maui#11676, @rolfbjarne suggested that this might be a dotnet/runtime repo so I took the opportunity to file the issue here. I'm sorry if this is not correct place. Feel free to close the issue if it does not belong here.

Reproduction Steps

Modify a sample MAUI app as follows:

using System;

public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new AppShell();

        AppDomain.CurrentDomain.ProcessExit += this.OnProcessExit; // Added line.
    }

    // This method is not called on macOS but it is called on Windows.
    private void OnProcessExit(object sender, EventArgs e)
    {
        throw new Exception("REACHED?");
    }
}

Expected behavior

I expect OnProcessExit to be called.

Actual behavior

OnProcessExit method is NOT called.

Interestingly though, in a standard .NET console app on macOS (i.e net7.0), CurrentDomain_ProcessExit is called:

public static class Program
{
    public static void Main(string[] args)
    {
        AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
    }

    private static void CurrentDomain_ProcessExit(object? sender, EventArgs e)
    {
        throw new NotImplementedException();
    }
}

So the issue seems to be MAUI specific.

Regression?

No response

Known Workarounds

I have not found any.

Configuration

macOS M1, .NET 7 (i.e. latest released version)

Other information

No response

Author: MartyIX
Assignees: -
Labels:

untriaged, area-VM-meta-mono, os-maccatalyst

Milestone: -

@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Nov 29, 2022
@marek-safar marek-safar added this to the 8.0.0 milestone Nov 29, 2022
@MartyIX
Copy link
Contributor Author

MartyIX commented Jan 20, 2023

@steveisok @akoeplinger Any progress on this one please? Anything I can help with potentially?

@steveisok
Copy link
Member

@akoeplinger Please take a look at this when you have a moment.

@steveisok steveisok modified the milestones: 8.0.0, 9.0.0 Aug 8, 2023
@lewing lewing assigned vitek-karas and unassigned akoeplinger Feb 21, 2024
@vitek-karas vitek-karas removed their assignment Feb 27, 2024
@vitek-karas vitek-karas modified the milestones: 9.0.0, Future Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants