Skip to content

ManagedError: EndOfStringNotFound when starting Blazor in BlazorWebAssembly application with AoT #111151

Closed
@Kizuto3

Description

@Kizuto3

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I encountered an issue with Blazor wasm where non-primitive (class and struct) arguments passed through JSInterop are failing to be parsed with EndOfStringNotFound exception for both cases where arguments are passed from dotnet to JS and from JS to dotnet. However, this issue appears to be environment dependent, as it's only reproduceable on our machines in France and only with AoT compilation enabled. Without AoT compilation no issue is present.

Expected Behavior

Arguments should be passed successfully between JS and dotnet.

Steps To Reproduce

Example project: https://github.com/Kizuto3/Blazor-JavaScript-Interop

Steps:

  1. Make sure wasm tools are installed via running "dotnet workload install wasm-tools-net8".

  2. Publish the project to a desired folder.

  3. Host the project via IIS Manager. Here's my settings example:
    Image

  4. Open the hosted website in the browser and observe console via F12. I believe this issue depends on the environment, so it might work as expected on your machine. If everything is fine you should see a console log like "guid - string" appear in the console when mouse cursor leaves the website. If not, you should see an exception similar to the one in the Exceptions section below.

Exceptions (if any)

When passing arguments from dotnet to JS:
Image
I believe there is some code in Blazor.Start() JS method that invokes JSInterop and passes arguments from dotnet to JS.

When passing arguments from JS to dotnet:
Image
In this case there are 2 arguments: Guid and string, that are being passed from JS to dotnet.

.NET Version

8.0.11

Anything else?

Environment:
Image

ASP.NET Core shared framework version 8.0.11
Microsoft .NET Windows Server Hosting version 8.0.11

Publishing the project without AoT seem to fix the issue, so the root of this issue might be related to AoT compilation.
Please let me know if you need any more information.

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-Codegen-AOT-mononeeds-author-actionAn issue or pull request that requires more info or actions from the author.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions