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

Handling exception using UnhandledExceptionEvent in coreclr #111701

Closed
Liangjia0411 opened this issue Jan 22, 2025 · 2 comments
Closed

Handling exception using UnhandledExceptionEvent in coreclr #111701

Liangjia0411 opened this issue Jan 22, 2025 · 2 comments

Comments

@Liangjia0411
Copy link

When I call a C# method from C++ and try to handle exceptions thrown by the C# code using AppDomain.CurrentDomain.UnhandledException, it crashes.

It seems that even if the exception is caught by the UnhandledExceptionEvent, it still propagates further.
Image

How should I resolve this issue? The reason for using UnhandledExceptionEvent to handle exceptions is to maintain compatibility with Mono. In Mono, using mono_unhandled_exception to handle exceptions does not cause a crash.

Environment:

  • dotnet 9
  • Windows
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 22, 2025
@huoyaoyuan
Copy link
Member

UnhandledException can't handle exception. It can only do necessary logging etc and the application is terminated because of exception.

Exception across interop boundary is very limited. See https://learn.microsoft.com/dotnet/standard/native-interop/exceptions-interoperability

@jkotas
Copy link
Member

jkotas commented Jan 22, 2025

We have a new proposed API that allows you to "handle" the unhandled exceptions: #101560

cc @VSadov

@jkotas jkotas closed this as completed Jan 22, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jan 22, 2025
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

3 participants