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

6

6

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?

Maidstone answered 7/8, 2018 at 10:9 Comment(3)
A service reference you say? what framework/core version are you using just for curiosity sake.Angelicaangelico
did you try removing and adding mscorlib reference?ALso set use specific version to false in the reference properties.Alexia
4.6.1, and there's never been mscorlib in references. Project worked on another machines and not on my.Maidstone
P
4

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

Pushbike answered 25/9, 2018 at 19:32 Comment(0)
U
6

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!

Untune answered 24/10, 2019 at 13:9 Comment(1)
Sometimes just closing VS and reopening is enough.Fougere
G
5

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.

Grip answered 28/3, 2021 at 21:10 Comment(3)
I keep getting this and I have to toggle back and forth to get it to work as well. I started using "Target Framework Migrator" extension to get every project within the solution.Biagi
Solved Problem! Target framework changed to one lower, Build and again changed to 4.8Crossbow
Also delete /bin and /obj for good measure.Chorizo
P
4

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

Pushbike answered 25/9, 2018 at 19:32 Comment(0)
T
2

enter image description here

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

Triviality answered 8/9, 2021 at 10:1 Comment(0)
E
1

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.

Extensile answered 17/2, 2021 at 8:15 Comment(1)
Thank you! I cloned my project and replaced the application name everywhere using string replacement. It worked but it showed the mscorlib error. Deleting the bin and obj folders did it for me. Thank you!Er
W
0

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.

Werewolf answered 23/6, 2022 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.