Sdk: "Could not load file or assembly 'System.Runtime, Version=4.2.0.0'"

Created on 31 Jan 2017  路  21Comments  路  Source: dotnet/sdk

Steps to reproduce

  • dotnet new -t web1.1
  • dotnet restore
  • dotnet run

Expected behavior

Application started. Press Ctrl+C to shut down.

Actual behavior

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, 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)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc3-004530)

Product Information:
 Version:            1.0.0-rc3-004530
 Commit SHA-1 hash:  10b642bc12

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  14.04
 OS Platform: Linux
 RID:         ubuntu.14.04-x64
 Base Path:   /usr/share/dotnet/sdk/1.0.0-rc3-004530

Most helpful comment

I resolved this by navigating to C:\Users\...\AppData\Roaming\.Nuget\packages and deleting the existing microsoft.visualstudio.web.browserlink folder. Then run dotnet restore on the project folder.

All 21 comments

The issue here is that the version included in the CLI's offline package cache of Microsoft.VisualStudio.Web.BrowserLink version 1.1.0 seems to be broken.
If do rm -r ~/.nuget/packages/microsoft.visualstudio.web.browserlink and then run dotnet restore and dotnet run again, no issues occur.

I suppose a nightly dev-feed version of that package made it into the CLI? This repros in 1.0.0-rc3-004530 but the version included in 1.0.0-rc4-004711 is fine. Is this fixed permanently? If so, it should probably be marked as an RC3 known issue. cc @piotrpMSFT @livarcocc

MacBook-Pro:tmp martin$ cat ~/.nuget/packages/microsoft.visualstudio.web.browserlink/1.1.0/microsoft.visualstudio.web.browserlink.nuspec 
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>Microsoft.VisualStudio.Web.BrowserLink</id>
    <version>1.1.0</version>
    <authors>Microsoft</authors>
    <owners>Microsoft</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>A middleware that supports creating a communication channel between the development environment and one or more web browsers.</description>
    <tags></tags>
    <serviceable>true</serviceable>
    <dependencies>
      <group targetFramework=".NETFramework4.5.1">
        <dependency id="Microsoft.AspNetCore.Hosting.Abstractions" version="[1.1.0, )" />
        <dependency id="Microsoft.AspNetCore.Http.Abstractions" version="[1.1.0, )" />
        <dependency id="Microsoft.AspNetCore.Http.Extensions" version="[1.1.0, )" />
        <dependency id="Microsoft.Extensions.FileProviders.Physical" version="[1.1.0, )" />
      </group>
      <group targetFramework=".NETStandard1.5">
        <dependency id="System.Net.Sockets" version="[4.4.0-beta-24903-02, )" />
        <dependency id="System.Net.Primitives" version="[4.4.0-beta-24903-02, )" />
        <dependency id="System.IO.MemoryMappedFiles" version="[4.4.0-beta-24903-02, )" />
        <dependency id="System.Diagnostics.Tools" version="[4.4.0-beta-24903-02, )" />
        <dependency id="Microsoft.AspNetCore.Hosting.Abstractions" version="[1.1.0, )" />
        <dependency id="Microsoft.AspNetCore.Http.Abstractions" version="[1.1.0, )" />
        <dependency id="Microsoft.AspNetCore.Http.Extensions" version="[1.1.0, )" />
        <dependency id="Microsoft.Extensions.FileProviders.Physical" version="[1.1.0, )" />
      </group>
    </dependencies>
  </metadata>
</package>

@mlorbetske Any idea how we could have gotten a broken package here? Did we have a broken package publish to a feed somewhere at some point? The cache is constructed simply by doing a dotnet new, dotnet restore and the packaging the cache folder.

@jodavis any ideas?

Is there a different workaround for this on windows? Deleting the microsoft.visualstudio.web.browserlink folder from .nuget/packages and doing a new dotnet restore still results in the same error: Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, 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)

@stibay can you upload you obj/project.assets.json for the project you have problems with? Maybe also check if you have a custom nuget.config that sets a specific nuget server. And maybe take a look in the nuspec file of the browserlink package in your nuget cache if there are any 4.4.0-* packages listed in there

Hmm read this issue abit fast maybe. What I did was add a new Web Application (1.1 template) and add AspNetCore.SignalR v.1.0.0-preview1-23318. It's working before I add the SignalR package but after I add this I am getting that error so might be related to something else.

@stibay I don't see the package AspNetCore.SignalR on nuget.org. If restore is working for you, it strongly suggests there is a custom NuGet.config at play. Can you remove the custom feeds and give this a shot?

I am also having this issue on Windows and just started up a brand new project to reproduce:

dotnet new -t Web1.1
dotnet restore - Restore completes successfully in 2.6 seconds
dotnet build - Successfully produces the dll
dotnet run- Results in this exception:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, P
ublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRE
SULT: 0x80131040)

Here is the .csproj that is produced:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
</Project>

Removing <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /> from .csproj and commenting out app.UseBrowserLink(); in Startup.cs allowed this (very simple) program to build and run.

For now I am just going to try and work without BrowserLink on any 1.1 projects.

@dxetech there was an issue in the package in RC3. If you download the latest CLI from the root of this repo it already has the fixed layout.

@piotrpMSFT Thank you, that worked for me!

Great :)

I'm getting this issue with version 1.0.0-rc4-004915

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\EFCoreWebDemo>dotnet new mvc
Content generation time: 402.1011 ms
The template "ASP.NET Core Web App" created successfully.

C:\EFCoreWebDemo>dotnet restore
  Restoring packages for C:\EFCoreWebDemo\EFCoreWebDemo.csproj...
  Generating MSBuild file C:\EFCoreWebDemo\obj\EFCoreWebDemo.csproj.nuget.g.props.
  Generating MSBuild file C:\EFCoreWebDemo\obj\EFCoreWebDemo.csproj.nuget.g.targets.
  Writing lock file to disk. Path: C:\EFCoreWebDemo\obj\project.assets.json
  Restore completed in 2.33 sec for C:\EFCoreWebDemo\EFCoreWebDemo.csproj.

  NuGet Config files used:
      C:\Users\mikebrind\AppData\Roaming\NuGet\NuGet.Config

  Feeds used:
      https://www.nuget.org/api/v2/

C:\EFCoreWebDemo>dotnet run

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Sys
tem.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The l
ocated assembly's manifest definition does not match the assembly reference. (Exceptio
n from HRESULT: 0x80131040)

dotnet --info:

C:\EFCoreWebDemo>dotnet --info
.NET Command Line Tools (1.0.0-rc4-004915)

Product Information:
 Version:            1.0.0-rc4-004915
 Commit SHA-1 hash:  4d66827e01

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-rc4-004915

I resolved this by navigating to C:\Users\...\AppData\Roaming\.Nuget\packages and deleting the existing microsoft.visualstudio.web.browserlink folder. Then run dotnet restore on the project folder.

Hit this issue as well.

Deleting from C:\Users....nuget\packagesmicrosoft.visualstudio.web.browserlink worked for me as well.

I have downgraded from Microsoft.VisualStudio.Web.BrowserLink (1.1.1) to Microsoft.VisualStudio.Web.BrowserLink (1.0.1) and it solved my problem. VS2017 Asp.Net Core 1.1 project.

Removed the reference and it works!

@mlorbetske since some more people are hitting this for various reasons, would it be possible to release a patch version (1.1.1) on nuget and future template updates to address the issue?
(Latest user hitting this was @pauldotknopf via Slack)

@dasMulli I'll talk this over with @sayedihashimi early next week. It's possible to do, but we'll want to do a test pass & figure out on what cadence we'll be releasing to NuGet beyond our first release there.

@mlorbetske let's try and chat today if possible

Any update on this, @mlorbetske and @sayedihashimi? My project didn't compile because Stream was defined in two different assemblies. Googling that brought me nowhere. Microsoft.VisualStudio.Web.BrowserLink being the culprit didn't occur to me at all...

Is there any reason not to release a patch version, as @dasMulli suggests?

Just hit this issue as well. Visual Studio should print an error message at least - now it just starts and then kills the process without a sound. Using the command line reveals the issue of missmatching assemblies

Was this page helpful?
0 / 5 - 0 ratings