0
votes

I've got a really frustrating error in Visual Studio 2013. For some projects I need .Net 4.5 so I've installed that framework. Now I get problems with any project targetting .Net 4.0 - a dialog tells me 'The project is targetting ".NETFramework,Version=v4.0" which is not installed on this machine.'

I've tried going to the Microsoft website to download the targetting pack for this version, but it tells me that .Net v4.0 itself is not installed so the targetting pack refuses to install as well. Repairing VS 2010 and/or VS 2013 does nothing to fix the problem.

What can I do? I can't change the project to target v4.5 but my machine now seems to reject lower versions!

2
Why are you downloading the targeting pack and not the framework 4 itself from microsoft.com/en-us/download/details.aspx?id=17851? Try to do that and then reset Visual Studio at runtime so it can pick up the frameworks correctly. However, the safest path would be to remove 4.5, install 4.0 and then reinstall 4.5. - Faris Zacina
Thanks, I just tried that. I uninstalled everything, then installed .Net 4.0 which seemed to go fine, then 4.5.2 (which is the most up-to-date I could find). This seemed to remove v4.0 from my machine so I'm back in the same state as before. - Dave
Its really hard to answer to this type of questions and give good advice :) The next option is to remove all VS (2010 and 2013) and all .NET frameworks, and then install only 2013, and .net 4.5 with the targeting pack (unless you need VS 2010 build tools for C++ etc.). In normal conditions VS 2013 should target 4.0 without issues. - Faris Zacina
Thanks for the extra advice. I've ended up uninstalling and reinstalling everything and I think that may have done the trick. No idea what had been removed or whatever but hopefully it's fixed now. - Dave
Great. I am happy i could help ;) its always frustrating dealing with that kind of stuff. - Faris Zacina

2 Answers

1
votes

It's hard to answer, because the problem is very strange. But there can be hints to solution:

  1. 4.5 is an update to 4.0 you can .NET Framework 3.5 and 4.5 side by side, but not 4.0 and 4.5. Do not waste your time on installing them in different order.
  2. VS2013 uses a different MSBuild, which is a part of VS2013. Previously it was a part of .NET Framework. Look at your csproj files and try to change MSBuild from 11 to 12 (the new path is %ProgramFiles%\MSBuild\12.0\bin)
0
votes

You can try the following step to repair your Visual Studio

Control Panel\Programs\Programs and Features > Select your Visual Studio > Change > Repair

Or you also can try

Control Panel\Programs\Programs and Features > .NET 4.5 > Repair

Hopefully this help