VS Community - Cannot run a simple console application: Could not load file or assembly ‘System.Reflection.Metadata' - visual-studio

I’ve installed Microsoft Visual Studio Community 2019 Version 16.9.4 and tried to create a simple console application to print “Hello World”.
If I run the app with dotnet run from the Windows Command Prompt, it will run successfully, but opening the project in VS and trying to start the console app is causing the following error:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly ‘System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)
I’ve already tried to start the console app as x86 and x64, but that did not help.
Another attempt was to uninstall VS 2019 and install VS 2017 Community. Have the same exception when I build the console app.
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)
Could someone please help me with this?

Related

"XAMLTaskFactory" could not be loaded from Assembly

I've been trying to run x86 assembly code on my machine for schoolwork. Sadly I've been getting this error when trying to build the project files and I can't figure out what it's about and how to fix it:
Error MSB4175 The task factory "XamlTaskFactory" could not be loaded from the assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". The system cannot find the path specified hi C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets 70
Has anyone had the same problem? I've tried making new projects, running as administrator, done a clean install of Visual Studio and all the packages, even factory reset my laptop.

Visual Studio Installer - Unable to acquire updated Visual Studio Installer

I have a problem with installing Visual Studio 2022 from https://visualstudio.microsoft.com/fr/downloads/
I got this error when I try to run VisualStudioSetup.exe .This is my first attempt
Unable to acquire updated Visual Studio Installer. This problem occurs when the installer on your machine is the same or lower than the version to update. If this is your first attempt, we recommend that you Continue to install the Visual Studio update.
[Continue] [Cancel]
When I click continue and this error appear
Unable to launch the installer. Error: Could not load file or assembly 'System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
I 've try to unistall and ran setup.exe again but it didn't work..

Could not load file or assembly 'System.Web.RegularExpressions, Version=4.0.0.0

Last night I upgraded my Visual Studio 2017 to the latest version 15.7.0. Since then all my projects are not running any more.
The error I am getting:
Could not load file or assembly 'System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I tried adding manually a referece to the DLL, I am still getting the error
I fixed the issue by 1) updating Visual Studio from 15.7.0 to 15.7.1 2) repairing the installation

Visual Studio F# error - FSharp.Core.sigdata

I've installed the latest FSharp bundle, but now whenever I hit control-spacebar in Visual Studio, I get this error:
Problem reading assembly 'FSharp.Core, Version=4.3.1.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': Error opening
binary file
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.3.1.0__b03f5f7f11d50a3a\FSharp.Core.dll':
FSharp.Core.sigdata not found alongside FSharp.Core
Edit 1
Also, when I try to compile, I get the following errors:
FSC: error FS1223: FSharp.Core.sigdata not found alongside FSharp.Core
FSC: error FS0229: Error opening binary file 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.3.1.0__b03f5f7f11d50a3a\FSharp.Core.dll': FSharp.Core.sigdata not found alongside FSharp.Core
FSC: error FS3160: Problem reading assembly 'FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': Error opening binary file 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.3.1.0__b03f5f7f11d50a3a\FSharp.Core.dll': FSharp.Core.sigdata not found alongside FSharp.Core
Done building project "Library1.fsproj" -- FAILED.
Edit 2
On top of that, I get the following errors when I try to run fsi.exe:
> Session termination detected. Press Enter to restart.
unknown(1,1): error FS1223: FSharp.Core.sigdata not found alongside FSharp.Core
unknown(1,1): error FS0229: Error opening binary file 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\FSharp.Core\v4.0_4.3.1.0__b03f5f7f11d50a3a\FSharp.Core.dll': Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+StopProcessing' was thrown.
unknown(1,1): error FS3160: Problem reading assembly 'FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a': Exception of type 'Microsoft.FSharp.Compiler.ErrorLogger+StopProcessing' was thrown.
Note: I can still run fsi.exe for F# 3.0. I'm only having this issue with 3.1 (C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0)
Any idea how I can get back to functioning F#?
Edit 3
It appears that I am again able to compile my F# projects after numerous repair installs/system reboots of things. The issues with fsi.exe and Visual Studio Intellisense remain.

Error loading Visual Studios 2012

Everytime i try to open Visual Studios 2012, an error message displays
" Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e25' or one of its dependencies. The system cannot find the file specified."
Any idea what is wrong? How to fix this?
Try to Uninstall the Visual Studio that you have and download it from http://www.microsoft.com/visualstudio/esn/2013-preview. It works for me perfectly.

Resources