-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled exception. System.BadImageFormatException #5224
Comments
Reverting to 1.24.4 works. |
@StacyCMay This likely means that you have the x64 build of the .NET SDK installed. If you uninstall and install the arm64 instead, it should start up fine. Sorry for the inconvenience. |
I can confirm that we must revert back to 1.24.4 if on a MacOS with M1 arm64 CPU and x64 dotnet SDK installed |
This worked for me too, thanks! |
I will close this because it is the expected behavior. Having just the emulated x64 on arm64 is not the supported scenario by OmniSharp. However, you can first install arm64 dotnet, and then install x64 dotnet in which case, dotnet installer places it under the x64 folder:
In this case you could always toggle to x64 by running e.g. |
Would you happen to know how I would go about setting my default base path to the arm64 SDK? I installed x64 first and I just installed arm64 today but I don't know how I get dotnet linked to that new SDK. When I type in dotnet --info it still gives me information about the old x64 SDK with the incorrect base path. |
This is mostly outlined here by Rich dotnet/sdk#22380 (comment)
Then you would first install arm64 dotnet as this is the recommended variant for arm devices, and if you still need x64 for some specific reason, you install it second. Then arm64 dotnet is your "main" one, and you can "opt into" x64 by either doing a temporary export, creating a specific alias (such as |
Thanks. After reinstalling .net and configuring the settings in vscode to use the right mono path, I got the new version of the plugin to work with unity code. |
Using the Arm build isn’t an option for my team. We’re working on a project that relies on PostSharp, which appears to have no intention of supporting Arm. OmniSharp was working for us prior to 1.25. |
@adamshaylor We can look at adding an option for Mac users to override the detected architecture. But until a change like that goes in, you have a couple options at this time:
|
We’re also looking into migrating to PostSharp metalama. It’s not a one-to-one replacement, but if we understand correctly, uses Rosylyn under the hood and therefore in theory would allow us to run .NET natively on Arm architecture if we can port our existing code to use it. |
If you found this issue by Googling the error message, it might be worth trying out |
Issue Description
Unhandled exception. System.BadImageFormatException
Steps to Reproduce
Upgraded to version 1.25.0
Expected Behavior
CSharp extension loads without error
Actual Behavior
Unhandled exception. System.BadImageFormatException
Could not load file or assembly '~/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'. An attempt was made to load a program with an incorrect format.
Logs
OmniSharp log
C# log
OmniSharp server started with .NET 6.0.300
.
Path: ~/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll
PID: 10191
Unhandled exception. System.BadImageFormatException: Could not load file or assembly '~/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'. An attempt was made to load a program with an incorrect format.
File name: '~/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/.omnisharp/1.39.0-net6.0/OmniSharp.dll'
Environment information
VSCode version: 1.67.2
C# Extension: 1.25.0
Mono Information
OmniSharp using mono :6.12.0Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.300 Commit: 8473146e7dRuntime Environment:
OS Name: Mac OS X
OS Version: 12.4
OS Platform: Darwin
RID: osx.12-x64
Base Path: /usr/local/share/dotnet/x64/sdk/6.0.300/
Host (useful for support):
Version: 6.0.5
Commit: 70ae3df4a6
.NET SDKs installed:
3.1.416 [/usr/local/share/dotnet/x64/sdk]
3.1.417 [/usr/local/share/dotnet/x64/sdk]
3.1.418 [/usr/local/share/dotnet/x64/sdk]
3.1.419 [/usr/local/share/dotnet/x64/sdk]
5.0.404 [/usr/local/share/dotnet/x64/sdk]
5.0.405 [/usr/local/share/dotnet/x64/sdk]
5.0.406 [/usr/local/share/dotnet/x64/sdk]
5.0.407 [/usr/local/share/dotnet/x64/sdk]
5.0.408 [/usr/local/share/dotnet/x64/sdk]
6.0.101 [/usr/local/share/dotnet/x64/sdk]
6.0.102 [/usr/local/share/dotnet/x64/sdk]
6.0.103 [/usr/local/share/dotnet/x64/sdk]
6.0.104 [/usr/local/share/dotnet/x64/sdk]
6.0.105 [/usr/local/share/dotnet/x64/sdk]
6.0.300 [/usr/local/share/dotnet/x64/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.22 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.23 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.24 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.25 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.13 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.14 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.15 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.16 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.4 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.22 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.23 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.24 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.25 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.13 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.14 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.15 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.16 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.4 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
The text was updated successfully, but these errors were encountered: