Troll the Legacy
Troll the Legacy

Reputation: 715

Could not resolve mscorlib for target framework '.NETFramework,Version=v4.6.1'

When I'm trying to update or configure service reference in .NET 4.6.1 project, VS throws next error:

Could not resolve mscorlib for target framework '.NETFramework,Version=v4.6.1'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.

Path lenght is OK, I'd also checked another answers on SO and nothing works. Maybe someone has something like that?

Upvotes: 6

Views: 22307

Answers (6)

Mr.President
Mr.President

Reputation: 31

In my situation; I was rebuilding a projected I had worked on using Visual Studio 2010. To resolve this error, I downloaded the .NET Framework 4.8 Developer Pack via this site https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk I restarted my IDE and everything was fine.

Upvotes: 0

P. Gong
P. Gong

Reputation: 29

enter image description here

You should refresh the target framework in the Application properties of the project

Upvotes: 3

AndersK
AndersK

Reputation: 36082

I had the same issue with VS 16.10.0 Preview 1.0 for 4.8

To fit it I did first clean project, then retargeted from 4.8 to 4.7.2 and back and then it worked.

Upvotes: 5

Matas Vaitkevicius
Matas Vaitkevicius

Reputation: 61401

In my case going into the project folders and manually deleting contents of:
/bin
/obj of each project in the solution. And then contents of
/packages in solution folder
then reopening solution and rebuilding + restoring the nuget packages worked.

Upvotes: 1

Luca Ritossa
Luca Ritossa

Reputation: 1185

I get the same error on VS2019.
This error occurred because I never restored nuget packages and built the solution.

After a restore of nuget packages and a full rebuild of the solution the error disappeared!

Upvotes: 6

Paul Schroeder
Paul Schroeder

Reputation: 1601

It is hard to confirm, but I believe my issue had to do with exceeding a TFS limit of 259 characters in the path. In short, when getting latest from TFS, I think some files were not downloading to my local machine due to their path exceeding 259 characters.

After renaming the working directory to a shorter path, I was able to configure existing and new service references. Here's one link discussing the limitation: TFS Path Too Long Problems

Upvotes: 4

Related Questions