Jess
Jess

Reputation: 353

Visual Studio 15.3.1 can't find core DLLs after update

I'm getting the runtime error:

InvalidOperationException: Can not find assembly file mscorlib.dll at '...\bin\Debug\net462\refs,...\bin\Debug\net462\'

This had not been a problem until I updated to version 15.3.1 this morning, and installed the .Net Core 2.0 SDK.

The DLL's are present in my ~\.nuget\packages folder. I'd had the same issue with the "Microsoft.Csharp.dll" assembly until I copied and pasted it into the stated folder.


I tried specifying to use .Net Core 1.1.0 via a global.json file, but then I get the build error:

The version of Microsoft.NET.Sdk used by this project is insufficient to support references to libraries targeting .NET Standard 1.5 or higher. Please install version 2.0 or higher of the .NET Core SDK.

This error goes away if I clean the solution then restore Nuget packages via Command Line- not via the GUI. However it comes back if I change the version of a nuget package.

Upvotes: 3

Views: 988

Answers (1)

RemarkLima
RemarkLima

Reputation: 12037

OK, this seem slightly different to my issue here: Visual Studio update 2017 15.3.1 forces ASP.NET Core SDK 2.0, which then doesn't find "reference assemblies"

If you install the SDK 2.0 from https://www.microsoft.com/net/download/core

You will then "probably" be able to build and run the project again but you'll be back to having the missing Microsoft.CSharp.dll / mscorelib.dll error.

If you then make sure the dependency is correct for the netstandard version:

<DependsOnNETStandard>netstandard1.5</DependsOnNETStandard>

See here: https://learn.microsoft.com/en-us/dotnet/standard/net-standard for the right version for you. My project is using core 1.1 targeting the full framework 4.6.1 and targeting netstandard1.6 has worked for me.

The final piece of the puzzel, was found on the GitHub issues here: https://github.com/dotnet/sdk/issues/1488

Add the following to your references in the .csproj file:

<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" />

This will then build the project as a 1.1 project, but using the 2.0 SDK (which from what I can tell, it's supposed to do!). I can now run the project, update packages and generally got on with my work!

Upvotes: 3

Related Questions