Visual Studio .Net Target Framework Version is grayed out

Viewed 3808

I am using Visual Studio 2015 to open a C++ CLI project and I want it to target .NET 4.5. My installed .NET version is 4.7. But I cannot edit the project's target framework because it is grayed out.

Grayed out target framework version

I have tried to directly edit the project's file in notepad but I couldn't find where the target framework is defined.

Below is part of the screenshot of the .vcxproj file

Project file xml screenshot

3 Answers

To complete Hao Peng's answer.

  1. Right click on project.
  2. Select "Unload Project"
  3. Right click on unloaded project.
  4. Select "Edit *.vcxproj"
  5. Modify the "TargetFrameworkVersion" tag from "v4.7" to "v4.5"
  6. Save and close the file
  7. Right click on unloaded project
  8. Select "Reload Project"

This feels a bit hacky; nevertheless, it worked for me. I moved from 4.5.2 to 4.5. YMMV.

In Visual Studio, in Solution Explorer, select your project. On the menu bar, open the Project menu and choose Unload project. This unloads the project (.vcxproj) file for your project.

In my case, I had this issue, while doing migration from .netframework to .net core.

I have multiple projects in my solution, of which base project was created with output type as Class Library and Target framework is set to '.net5.0-windows' by a tool and the other projects are created as '.netstandard 2.0'. Though the dependent projects are configured correctly in .csproj, the option in the properties is grayed out.

However, when I changed base project targetframework to '.netstandard 2.0' then the Target framework has all installed '.netstandard' versions for rest of the projects.

Related