Skip to content

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

@sturlath

Description

@sturlath

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

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<Import Project="..\..\common.props" />

<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework>
  <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
  <BlazorWebAssemblyEnableLinking>true</BlazorWebAssemblyEnableLinking>
  <PublishTrimmed>true</PublishTrimmed>
  <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
  <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

<ItemGroup>
  <ProjectReference Include="..\BSR.Beinni.HttpApi.Client\BSR.Beinni.HttpApi.Client.csproj" />
</ItemGroup>

<ItemGroup>
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-100.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-200.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-300.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-600.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-600italic.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-700.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-700italic.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-italic.woff2" />
  <None Include="wwwroot\assets\fonts\poppins-v6-latin-regular.woff2" />
</ItemGroup>

	<ItemGroup>
		<PackageReference Include="BlazorDownloadFileFast" Version="0.2.0" />
		<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" />
		<PackageReference Include="Blazorise.Charts" Version="1.0.4" />
		<PackageReference Include="Blazorise.SpinKit" Version="1.0.4" />
		<PackageReference Include="Blazorise.Video" Version="1.0.4" />
		<PackageReference Include="Blazorise.Bootstrap5" Version="1.0.4" />
		<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.0.4" />
		<PackageReference Include="Blazorise.Components" Version="1.0.4" />
		<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.5" />
		<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.5" PrivateAssets="all" />
		<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
		<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.6" />
		<PackageReference Include="Mindscape.Raygun4Net.NetCore" Version="6.4.3" />
		<PackageReference Include="Syncfusion.Blazor.FileManager" Version="20.1.0.61" />
		<PackageReference Include="Volo.Abp.AspNetCore.Components.Web.Theming" Version="5.3.2" />
		<PackageReference Include="Volo.Payment.Admin.Blazor" Version="5.3.2" />
		<PackageReference Include="Volo.Payment.Admin.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.Autofac.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.SettingManagement.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.Identity.Pro.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Saas.Host.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.AspNetCore.Components.WebAssembly.LeptonTheme" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.LeptonTheme.Management.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.Account.Pro.Admin.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.Account.Pro.Public.Blazor" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.TextTemplateManagement.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.AuditLogging.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.LanguageManagement.Blazor.WebAssembly" Version="5.3.2" />
		<PackageReference Include="Volo.Abp.IdentityServer.Blazor.WebAssembly" Version="5.3.2" />
	</ItemGroup>
</Project>

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]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions