Could not load type 'Microsoft.Build.Framework

2020-02-05 08:21发布

After doing an (apparently successful) upgrade from VS 2017 15.1 to 15.3, I can no longer load any C# project (can't open existing, can't create new). All fail with this error:

Could not load type 'Microsoft.Build.Framework.SdkReference' from assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

I found one reference to someone running into this problem with an RC version of 15.3, but no others, so I've got no idea what about my environment might be causing this problem. I've tried clearing cache and user data, repair, complete uninstall/reinstall, and removing 3rd party components. I am out of ideas.

There's absolutely tons of info I could provide here, so I'm not sure where to start. I'm grateful for any ideas or at least to see if others are running into the same problem.

3条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-02-05 08:55

I ran into a very similar issue after installing Visual Studio 2015 on a machine that already had Visual Studio 2017.

Re-installing Microsoft.Build.Framework into the GAC solve my issue.

查看更多
等我变得足够好
3楼-- · 2020-02-05 09:10
  1. open Developer Command Prompt for VS2017 (I opened it as admin)
  2. gacutil /u Microsoft.Build.Framework

to uninstall the Microsoft.Build.Framework from Global Assembly Cache [GAC]

  1. gacutil /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Build.Framework.dll"

to re-install the 15.1.0 version.

Now the projects in solutions load properly.

查看更多
老娘就宠你
4楼-- · 2020-02-05 09:12

Use an adminstrator "Developer Command Prompt for VS 2017" to run

gacutil /u "Microsoft.Build.Framework, Version=15.1"

Please do not reinstall another version to the GAC. MSBuild should not be in the GAC, and installing it there will cause problems the next time Visual Studio updates MSBuild, because the file from the GAC gets preferred over the updated version delivered with Visual Studio.

查看更多
登录 后发表回答