0

I have a new laptop with Windows 10. I installed the latest Visual Studio 2017. I opened up the c# solution which I had previously been working on a Windows 7 laptop with an older version of Visual Studio 2017 (i.e. not the latest update). The only difference with the setup is that the new install has .net framework 4.6.1 vs 4.8. when I try to build I get the following error:

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The module was expected to contain an assembly manifest. C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 52

I did try to revert back to 4.6.1. I also tried most of the suggested solutions in any previous questions with "could not load file or assembly"

  • Have you tried reinstalling the Microsoft.CodeAnalysis.Analyzers Nuget package, because it sounds like that assembly might be corrupt. In VS, open your Package Manager Console window (View > Other windows), and enter the command `update-package Microsoft.CodeAnalysis.Analyzers -reinstall`. – howcheng Sep 12 '19 at 22:02
  • @howcheng No I hadn't tried that but it didn't work either. I get the same error. However, I uninstalled VS again and reinstalled it and it seems like now everything is fine. Thanks for your suggestion. – Diddley Daddy Sep 13 '19 at 18:01

1 Answers1

1

I was able to resolve the issue by reinstalling VS 2017. I had tried this previously to no avail but this time it was successful. One difference was I also uninstalled VS 2019 and only reinstalled VS 2017.