Assembly Exception in ASP.Net Core Angular project

1

I have an ASP.NET Core Angular web application. I created this project with Visual studio 2017 angular template. I made a very basic application with the newest dependencies:

  • Microsoft.AspNetCore.All (2.0.7) as NuGET
  • Microsoft.NETCore.App (2.0.0) as SDK

We can build the application but when debugging , we encounter an exception as below:

System.IO.FileLoadException HResult=0x80131040 Message=Could not load file or assembly 'System.ComponentModel.Primitives, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Microsoft.Extensions.FileProviders.Physical

Here is the StackTrace:

StackTrace: at Microsoft.Extensions.FileProviders.PhysicalFileProvider.CreateFileWatcher(String root) at Microsoft.AspNetCore.Hosting.Internal.HostingEnvironmentExtensions.Initialize(IHostingEnvironment hostingEnvironment, String applicationName, String contentRootPath, WebHostOptions options) at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at WebApp.Program.BuildWebHost(String[] args) in D:\Source\WebApp\Program.cs:line 21 at WebApp.Program.Main(String[] args) in D:\Source\WebApp\Program.cs:line 17

We tried going to older versions of ASP.NET Core and back. The issue solves but next time we open the project the same exception happens. We cannot change the version of the Microsoft.NETCore.App (2.0.0) to newer versions because it is blocked by the project.

Note that we have changed the location of NugetPackages to be in specific folder (D:\Source\Library) (for the purpose of source control).

c#
asp.net
asp.net-core
nuget-package
asked on Stack Overflow May 3, 2018 by SillyPerson • edited May 16, 2018 by Ritwick Dey

1 Answer

0

Disable the runtime assembly specific on execution by adding the following to your project.json, under "frameworks":

"System.ComponentModel.Primitives": {
  "version": "4.1.0", // or whatever version you have
  "exclude": "runtime"
},

This is a workaround. It is happening because the platform-specific version of the System.ComponentModel.Primitives is not yet released for every platform - e.g. Ubuntu. More details here.

answered on Stack Overflow May 20, 2018 by Bozhidar Stoyneff

User contributions licensed under CC BY-SA 3.0