Skip to content

Exception in BlazorWasm applications due to NullabilityInfoContext usage #102848

@sebastienros

Description

@sebastienros

Description

This was introduced in #102499. This blocking runtime ingestion in ASP.NET for preview 5.

This exception is thrown when running a BlazorWasm application.

NullabilityInfoContext is not supported in the current application because 'System.Reflection.NullabilityInfoContext.IsSupported' is set to false. Set the MSBuild Property 'NullabilityInfoContextSupport' to true in order to enable it.

The BlazorWebAssembly SDK disabled the feature https://github.com/dotnet/sdk/blob/a304e06708d72c1be0d78e214366a2c7c601b5d8/src/BlazorWasmSdk/Targets/Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets#L49

This method should check NullabilityInfoContext.IsSupported is true before using calling NullabilityInfoContext.Create.

Reproduction Steps

Run a BlazorWebAssembly application like this one:

https://github.com/dotnet/aspnetcore/blob/release/9.0-preview5/src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj

Expected behavior

Application should not throw an exception when the System.Reflection.NullabilityInfoContext.IsSupported flag is false.

Actual behavior

An exception is thrown.

Regression?

Yes

Known Workarounds

Enable the System.Reflection.NullabilityInfoContext.IsSupported switch.

Configuration

No response

Other information

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions