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).

Ritwick Dey
  • 18,464
  • 3
  • 24
  • 37
SillyPerson
  • 589
  • 2
  • 7
  • 30
  • Hope you have set the `repositoryPath` for properly pointing the Nuget path – Developer May 14 '18 at 09:25
  • @Developer : I did not set the repositoryPath since based on documentation it is only applied to projects using packages.config. globalPackagesFolder applies only to projects using the PackageReference format. So I have set globalPackagesFolder to the NugetPath (D:\Source\Library) – SillyPerson May 14 '18 at 11:38
  • have you checked this SO question https://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference. It is trying to find System.ComponentModel.Primitives, Version=4.2.0.0, but can't find the specified version. – ash May 16 '18 at 06:12
  • did you check this issue https://github.com/dotnet/sdk/issues/803 – Aravind May 16 '18 at 06:20
  • 1
    Checking on the NuGet page for the [System.ComponentModel.Primitives](https://www.nuget.org/packages/System.ComponentModel.Primitives/) package, there isn't a 4.2.0 build. Strange. – Jamie Taylor May 16 '18 at 13:39

1 Answers1

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.

Bozhidar Stoyneff
  • 3,576
  • 1
  • 18
  • 28
  • .Net Core is based on msbuild, which means that it uses *.csproj instead of project.json. Anyhow, I updated .csproj to exclude runtime from the reference, but the problem remains. did you test this workaround in .net core .csproj file? – SillyPerson May 22 '18 at 08:53