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.UnhandledException doesn't get called #27

Open
andyld97 opened this issue Feb 7, 2022 · 6 comments
Open

AppDomain.CurrentDomain.UnhandledException doesn't get called #27

andyld97 opened this issue Feb 7, 2022 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@andyld97
Copy link

andyld97 commented Feb 7, 2022

Version

ver 2.1.0

Details

According to #23 I've made this little project:
UnhandledExceptionsRepro.zip

The problem is that the AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; event handler doesn't get called when using DotnetRuntimeBootstrapper.
I think the sample app is very easy to understand, so I don't think it needs more explanation here (I also added comments).

Steps to reproduce

Just click the button and read the comments.

@andyld97 andyld97 added the bug Something isn't working label Feb 7, 2022
@Tyrrrz Tyrrrz added the help wanted Extra attention is needed label Feb 7, 2022
@Tyrrrz Tyrrrz changed the title CurrentDomain_UnhandledException doesn't get called Feb 7, 2022
@Tyrrrz Tyrrrz changed the title AppDomain.CurrentDomain.UnhandledException doesn't get called Feb 7, 2022
@Tyrrrz
Copy link
Owner

Tyrrrz commented Feb 7, 2022

Still can't figure it out. Created a question here:
dotnet/runtime#64942

@Tyrrrz
Copy link
Owner

Tyrrrz commented Nov 30, 2022

Thought of a potential workaround to get the exception out: if the target assembly fails to run even after all prerequisites have been resolved, run it with dotnet CLI and get the output from stderr (which should contain the error message). No extra overhead on the hot/happy path.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Nov 30, 2022

Nevermind, it appears you can't use dotnet CLI once the application host is already initialized. And unfortunately you can't uninitialize/unload the host. 😒

@andyld97
Copy link
Author

But I think even if your idea would work, we would only get those exceptions at the startup? Or am I wrong? Because the actual problem is more like getting the unhandeld exception somewhere in your app when the user does something unexpected (if you know what I mean) 🤔

@Tyrrrz
Copy link
Owner

Tyrrrz commented Dec 1, 2022

Yeah, you're right. I was focused on my case where most of these exceptions do actually happen on startup.

Tyrrrz added a commit that referenced this issue Dec 1, 2022
…d exception (resulting in `SEHException` on bootstrapper's end)

Related to #27
@Tyrrrz
Copy link
Owner

Tyrrrz commented Dec 1, 2022

I found a way to at least show an error message to the user, although it still lacks the original exception message and stacktrace. Should at least not fail silently this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
2 participants