-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Blazor WASM] AppDomain.CurrentDomain.FirstChanceException event leads to exception after publish #69721
Comments
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. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsIs there an existing issue for this?
Describe the bugWhen using AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
{
Console.WriteLine("FIRST_CHANCE");
}; When testing locally during development this callback is fired as expected but not after publish. Expected BehaviorThe callback should fire no matter if app is published or not. Steps To ReproduceHere is a repro: This is a bare standard sample. To reproduce run the app locally, navigate to "Counter" page and then "Click me".
Now publish the app using default settings and repeat the process.
So the callback is not fired and we see something else. Exceptions (if any)
.NET Version6.0.300 Anything else?Blazor WebAssembly. dotnet --info
|
This is likely due to trimming since the calling code may be unmanaged and we may need to add a linker directive to preserve it. |
Is there any possible workaround for .NET 6? |
Seems that publishing using |
I tried this with the latest dotnet 7.0 preview, and I get .. but fails with the assertion on 6.0. And like @uhfath mentioned, this happens only when publishing. |
Preserving the constructor of |
Thanks for the info. |
Yes, it was backported to dotnet 6, correct. |
Is there an existing issue for this?
Describe the bug
When using
AppDomain.CurrentDomain.FirstChanceException
to subscribe for events the callback is not fired on published app:When testing locally during development this callback is fired as expected but not after publish.
![image](https://user-images.githubusercontent.com/14792749/170052873-d56fcab3-4c8e-4fb9-94f1-2be20bc24e83.png)
Settings used to publish are default:
Expected Behavior
The callback should fire no matter if app is published or not.
Steps To Reproduce
Here is a repro:
https://github.com/uhfath/TestBlazorDeploy
This is a bare standard sample.
The only addition is here:
https://github.com/uhfath/TestBlazorDeploy/blob/master/TestBlazorDeploy/InternalExceptionHandling.cs
To reproduce run the app locally, navigate to "Counter" page and then "Click me".
Open development console and note something like this:
Now publish the app using default settings and repeat the process.
This time the output is:
So the callback is not fired and we see something else.
Exceptions (if any)
.NET Version
6.0.300
Anything else?
Blazor WebAssembly.
Visual Studio 2022 (17.2.0).
dotnet --info
The text was updated successfully, but these errors were encountered: