UnhandledException not fire in publish(realsed) mode as exe
Hi,
Can you please check with sample code in the end of in this link:
https://github.com/dotnet/maui/issues/21007
why UnhandledException not work in reeased mode after publish.
public partial class App : Application {
public App() {
InitializeComponent();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private async void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
try { } catch (Exception) { } }
.NET MAUI
-
Dani_S 2,726 Reputation points
2024-03-25T09:54:16.9533333+00:00 Can you please answer ?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-03-26T08:21:44.5866667+00:00 Can you share reproduced steps when release this demo to exe? I get the error "Unable to build an app package becuase the app manifest is invalid. Correct the errors in the app manifest."
By the way,
Please try to add
GC.Collect();
in each page'sOnDisappearing
method. And I test it in debug mode, when I navigate to other pages (page1 -》page2->page3) Memory will not raising continuously.protected override void OnDisappearing() { base.OnDisappearing(); GC.Collect(); }
-
Dani_S 2,726 Reputation points
2024-03-26T08:27:34.1733333+00:00 dotnet publish -f net8.0-windows10.0.19041.0 -c Release -p:WindowsPackageType=None -p:WindowsAppSDKSelfContained=true -p:RuntimeIdentifierOverride=win10-x64
set maui as start project
right click on project name and open in terminal.
-
Dani_S 2,726 Reputation points
2024-03-26T08:53:24.7466667+00:00 Clean and rebuild the app before
-
Dani_S 2,726 Reputation points
2024-03-27T14:08:48.8533333+00:00 Dis you succeded?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-03-28T09:38:17.22+00:00 Yes, I release it. I use
throw new ArgumentException("ha-ha");
to make an exception, butAppDomain.CurrentDomain.UnhandledException
cannot catch it. I try to moveAppDomain.CurrentDomain.UnhandledException
to the login page and make an exception in it. It do not work.How did you make an exception?
-
Dani_S 2,726 Reputation points
2024-03-28T09:47:01.6966667+00:00 Same as you.
Please look on:https://github.com/dotnet/maui/issues/21485 they said:
@danies8 do you see this same behavior on a WinUI app without MAUI?
If so then we should probably move this issue over to the WinAppSDK repository
Can you also try updating to WinAppSDK 1.5 or a newer version of MAUI?
They fixed some things in there that might help
Is it true? can ypu please check ?
-
Dani_S 2,726 Reputation points
2024-03-29T06:51:30.38+00:00 Can you please answer?
-
Dani_S 2,726 Reputation points
2024-03-29T06:52:53.78+00:00 Are you using last version of Maui?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-03-29T07:13:50.82+00:00 My VS version is 17.9.4. If you want to use the latest version of MAUI, please update your VS to the latest.
Can you share your steps to make an exception that AppDomain.CurrentDomain.UnhandledException could catch it?
Do you want us to make a test with VS preview version?
-
Dani_S 2,726 Reputation points
2024-03-29T09:00:21.72+00:00 Try to throw exception in one of commands buttons in page 1
-
Dani_S 2,726 Reputation points
2024-04-01T07:19:52.4466667+00:00 Please look on:https://github.com/dotnet/maui/issues/21485 they said:
- Do you see this same behavior on a WinUI app without MAUI?
If so then we should probably move this issue over to the WinAppSDK repository
2.Can you also try updating to WinAppSDK 1.5 or a newer version of MAUI?
They fixed some things in there that might help
Is it true? can ypu please check ?
-
Dani_S 2,726 Reputation points
2024-04-02T09:03:40.99+00:00 Any answer?
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-04-03T05:48:10.48+00:00 Do you see this same behavior on a WinUI app without MAUI?
Which type of application do you want to test? UWP application or others? Can you share with us more information?
-
Dani_S 2,726 Reputation points
2024-04-03T05:50:47.2366667+00:00 ן want to test with Maui with the sample code I gave you in previous comment.
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-04-03T05:58:31.6533333+00:00 I test it in VS 17.9.5 with .NET 8. It is not working.
-
Dani_S 2,726 Reputation points
2024-04-03T06:07:52.0333333+00:00 Try to register and handler in main page
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,651 Reputation points • Microsoft Vendor
2024-04-10T06:58:58.2066667+00:00 Can you share more details about register and handler in main page?
Sign in to comment