Aspnetcore: Fatal error in Mono IL Linker (Blazor wasm)

Created on 23 May 2020  路  12Comments  路  Source: dotnet/aspnetcore

Describe the bug

Hi there,

I've noticed that every time I build (Release) my solution (with only one single POC project - Blazor wasm) the process always fails with:

```C#
Target _LinkBlazorApplication:
Fatal error in Mono IL Linker
C:\Users\EmilioV.nuget\packagesmicrosoft.aspnetcore.components.webassembly.build\3.2.0\targets\Blazor.MonoRuntime.targets(326,5): error : Unhandled exception. Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535'
---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'SQLitePCLRaw.core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1488e028ca7ab535'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
at Mono.Linker.LinkContext.Resolve(IMetadataScope scope)
at Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly)
at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences(AssemblyDefinition assembly)
at Mono.Linker.Steps.LoadReferencesStep.ProcessAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.BaseStep.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.Execute(String[] args, ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
C:\Users\EmilioV.nuget\packagesmicrosoft.aspnetcore.components.webassembly.build\3.2.0\targets\Blazor.MonoRuntime.targets(326,5): error : ILLink failed with exit code -532462766.

### To Reproduce
1 - Create a simple standalone Blazor-wasm solution/project. 
2 - Build the solution (Debug) and everything is okay - you are even able to run your app.
3 - Switch to Release and build (or build the solution for both env), and you'll start receiving the error message

This is my code, pretty simple, although I do not believe this issue has to do with the code. Instead, I believe it has to to with MSBuild...:

```C#
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace OneSpaWorld.Olympus.Manager
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<App>("app");

            builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));

            builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

            builder.Services.AddOidcAuthentication(options =>
            {
                builder.Configuration.Bind("OpenIdConnect", options.ProviderOptions);
            });

            await builder.Build().RunAsync().ConfigureAwait(false);
        }
    }
}

Further technical details

  • ASP.NET Core version: 3.1.4
  • The IDE (VS / VS Code/ VS4Mac) Windows 10 + VS2019 (16.6.0)
Answered Resolved area-blazor blazor-wasm

Most helpful comment

Same here https://github.com/Ealenn/WordMeaning/runs/759353844?check_suite_focus=true

  • Blazor WebAssembly
  • Framework: netstandard2.1
  • Razor: 3.0
  • Agent : Ubuntu

Edit:

You can build your app on windows agent :)

jobs:
  build:
    runs-on: windows-latest

https://github.com/Ealenn/WordMeaning/pull/1/checks?check_run_id=763314367

Edit 2:
No errors with a Docker build

All 12 comments

I applied the two most common hacks:

1 - Close/start again VS...no luck
2 - Restart (with all its variants) the PC - didn't work

thanks

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project (ideally a GitHub repo) that illustrates the problem.

Hi @mkArtakMSFT

Sure, this is the repo: https://github.com/emiliovmq/FatalErrorMonoILLinkerBlazorWasm

thanks

i've just had a similar thing with a github action

https://github.com/MrTortoise/dino_blazor_wasm/runs/707575685

I notice that you also have a reference to 3.2.0 whilst thinking you are on 3.1.x
Not sure if that is relevant!

(it all builds etc locally) (latest .net 3.1 installed)

Same here https://github.com/Ealenn/WordMeaning/runs/759353844?check_suite_focus=true

  • Blazor WebAssembly
  • Framework: netstandard2.1
  • Razor: 3.0
  • Agent : Ubuntu

Edit:

You can build your app on windows agent :)

jobs:
  build:
    runs-on: windows-latest

https://github.com/Ealenn/WordMeaning/pull/1/checks?check_run_id=763314367

Edit 2:
No errors with a Docker build

I have the same problem.

I am getting the same error too, works in Debug from VS, but trying to build a docker container with it in release, and I get this error. I changed my dockerfile to build Debug, and it now works. So at least there's a workaround for now.

You can reproduce this from the OAT Repo at https://github.com/Microsoft/OAT

image

Started happening with me after updating packages https://github.com/carlingkirk/emergence/runs/1040880391?check_suite_focus=true

going back from 3.2.1 to 3.2.0 AspNetCore.Components did fix build

I tried a couple of the repos listed here and updating to .NET 5 fixes the issue. .NET 5 RC1 is available for you to try out now, so feel free to try and update to it: https://get.dot.net/ https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-50?view=aspnetcore-3.1&tabs=visual-studio#update-blazor-webassembly-projects. @gfs updating your project resulted in a different error. I filed https://github.com/mono/linker/issues/1500 to track it.

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

Was this page helpful?
0 / 5 - 0 ratings