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

Blazor app is broken by AOT in .NET9.0 update #109894

Closed
Sean4572435243 opened this issue Nov 16, 2024 · 4 comments
Closed

Blazor app is broken by AOT in .NET9.0 update #109894

Sean4572435243 opened this issue Nov 16, 2024 · 4 comments

Comments

@Sean4572435243
Copy link

Sean4572435243 commented Nov 16, 2024

Description

Previously working Blazor code now broken by .NET9.0 when code is AOT'd. I had issues with my own code, but even with counterintuitive workarounds, I also had issues with established NuGet packages, such as using BouncyCastle encryption, which will be my example here

Reproduction Steps

NuGet package BouncyCastle.Cryptography version 2.4.0
For example
X9ECParameters x9EC = NistNamedCurves.GetByName("P-521");

Expected behavior

No Error

Actual behavior

Runtime error:
MONO interpreter: NIY encountered in method Org.BouncyCastle.Asn1.Nist.NistNamedCurves:.cctor ()

Regression?

Worked correctly in .Net8.0

Known Workarounds

This is one example of a symptom that I've experienced in multiple aspects of my app. I've refactored some code to convert interfaces to classes when the AOT version would generate these errors and that seems to work but I don't know why. I believe it has something to do with static elements in interfaces, but I wasn't able to reliably pin down a workaround strategy other than converting problematic interfaces to classes.

As much as I was able to perform workarounds with my own code, now this issue is impacting packages like BouncyCastle that I cannot manually modify with this workaround, so my code remains broken with no workaround other than the non-option of not AOT'ing the code.

Configuration

.NET9.0
Latest Win11 x64
doesn't appear related to my hardware
Problem appears in latest chrome

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Nov 16, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 16, 2024
@teo-tsirpanis teo-tsirpanis added area-Codegen-Interpreter-mono and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Nov 16, 2024
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@Sean4572435243 Sean4572435243 changed the title Blazor app using BouncyCastle encryption is broken by AOT in the latest .NET9.0 update Blazor app is broken by AOT in .NET9.0 update Nov 17, 2024
@BrzVlad
Copy link
Member

BrzVlad commented Nov 17, 2024

Please provide a complete repro app and steps manifesting this issue.

On macos, I tried a new blazorwasm template, added reference to the package, added X9ECParameters x9EC = NistNamedCurves.GetByName("P-521"); line to the button click callback, set RunAOTCompilation in the csproj and then published and used dotnet-serve on the folder publish, but wasn't able to reproduce.

Moved with trying to reproduce via visual studio and once again didn't get any crashes.

@Sean4572435243
Copy link
Author

Sean4572435243 commented Nov 17, 2024

Apologies, it was on my end. In my curated deployment script, some framework files were missed in my migration efforts to accommodate 9.0's new filename.HASH.wasm format, leading the the NIY errors. I didn't catch this because there were no clear errors that files were missing, other than what now seems as obvious clues in retrospect.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Nov 17, 2024
@BrzVlad
Copy link
Member

BrzVlad commented Nov 17, 2024

No problem, glad it worked out

@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants