dotnet / dotnet/linker

Blazor linking throws "Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object."

Open
#2,896 22 comments 0 reactions 0 assignees View on GitHub
area-Linker: Steps
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

When I run the following `dotnet publish --configuration Release ` on my Blazor WASM I get the error here below that doesn´t tell me anything useful

This is the content of my csproj if that helps

```

net6.0
true
true
true
service-worker-assets.js







































```

This the whole error

```
BSR.Beinni.Blazor -> C:\dev\IBeinni\aspnet-core\src\BSR.Beinni.Blazor\bin\Release\net6.0\BSR.Beinni.Blazor.dll
BSR.Beinni.Blazor (Blazor output) -> C:\dev\IBeinni\aspnet-core\src\BSR.Beinni.Blazor\bin\Release\net6.0\wwwroot
ILLink : error IL1012: IL Trimmer has encountered an unexpected error. Please report the issue at https://github.com/dotnet/linker/issues [C:\dev\IBeinni\aspnet-co
re\src\BSR.Beinni.Blazor\BSR.Beinni.Blazor.csproj]
Fatal error in IL Linker
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at Mono.Linker.TypeReferenceWalker.WalkMethodReference(MethodReference mr)
at Mono.Linker.TypeReferenceWalker.WalkTypeScope(MethodBody body)
at Mono.Linker.TypeReferenceWalker.WalkScopes(TypeDefinition typeDefinition)
at Mono.Linker.TypeReferenceWalker.Process()
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkModule(ModuleDefinition module, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArgument(CustomAttributeArgument argument, ICustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributeArguments(CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttribute(CustomAttribute ca, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference, DependencyInfo reason, Nullable`1 origin)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.MarkAssembly(AssemblyDefinition assembly, DependencyInfo reason)
at Mono.Linker.Steps.MarkStep.ProcessMarkedPending()
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
C:\Program Files\dotnet\sdk\6.0.400-preview.22301.10\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(109,5): error NETSDK1144: Optimizing assemblies fo
r size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [C:\dev\IBeinni\aspnet-core\src\BSR.Beinni.Blazor\BSR.Beinni.Blazor.cs
proj]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.