Skip to content
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

Omnisharp won't start or generate assets in vs code mac m1 #5132

Closed
gbubemismith opened this issue Mar 29, 2022 · 17 comments
Closed

Omnisharp won't start or generate assets in vs code mac m1 #5132

gbubemismith opened this issue Mar 29, 2022 · 17 comments
Assignees

Comments

@gbubemismith
Copy link

Environment data

dotnet --info output:
.NET SDK (reflecting any global.json):
Version: 5.0.405
Commit: 63325e1c7d

Runtime Environment:
OS Name: Mac OS X
OS Version: 12.2
OS Platform: Darwin
RID: osx-x64
Base Path: /usr/local/share/dotnet/x64/sdk/5.0.405/

Host (useful for support):
Version: 5.0.14
Commit: d5b56c6327

.NET SDKs installed:
3.1.416 [/usr/local/share/dotnet/x64/sdk]
5.0.405 [/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 5.0.14 [/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 5.0.14 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
VS Code version: 1.65.2
C# Extension version: v1.3.1

OmniSharp log

Starting OmniSharp server at 3/29/2022, 12:21:47 PM
Target: /Users/gbubemismith/Documents/coreApps/HardCore

OmniSharp server started.
Path: /Users/gbubemismith/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.3-beta.31/run
PID: 12046

System.TypeInitializationException: The type initializer for 'System.ComponentModel.TypeDescriptor' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Sys' threw an exception. ---> System.DllNotFoundException: System.Native assembly: type: member:(null)
at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
at Interop+Sys..cctor () [0x00000] in <36514b14425c4337b446653c547aa9c3>:0
--- End of inner exception stack trace ---
at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) [0x00000] in <36514b14425c4337b446653c547aa9c3>:0
at System.Guid.NewGuid () [0x00000] in <36514b14425c4337b446653c547aa9c3>:0
at System.ComponentModel.TypeDescriptor..cctor () [0x00034] in <4f55bbf82f9b4c60960312888c59bd5c>:0
--- End of inner exception stack trace ---
at OmniSharp.Internal.CommandOptionExtensions.GetValueOrDefault[T] (McMaster.Extensions.CommandLineUtils.CommandOption opt, T defaultValue) [0x00008] in :0
at OmniSharp.Stdio.StdioCommandLineApplication.get_Encoding () [0x00000] in :0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.

b__1 () [0x00000] in <4061e52126604f67b6d455853ab7baf7>:0
at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.b__0 () [0x0000b] in :0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication+<>c__DisplayClass146_0.b__0 (System.Threading.CancellationToken _) [0x00000] in :0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync (System.String[] args, System.Threading.CancellationToken cancellationToken) [0x000bf] in :0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00016] in :0
at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x00081] in :0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.b__0 () [0x00028] in <4061e52126604f67b6d455853ab7baf7>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in :0

Steps to reproduce

Try generating .net assets for build and debug

Expected behavior

.vscode is created and I cand run and debug my .net application

Actual behavior

I get System.TypeInitializationException: The type initializer for 'System.ComponentModel.TypeDescriptor' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Sys' threw an exception. ---> System.DllNotFoundException: System.Native assembly: type: member:(null)

@nohwnd
Copy link
Member

nohwnd commented Mar 29, 2022

I see you are using .NET5 x64 SDK, is that intentional? Your M1 should be better off using native arm64 which is available in .NET 6 https://dotnet.microsoft.com/en-us/download/dotnet/6.0 .

@gbubemismith
Copy link
Author

gbubemismith commented Mar 29, 2022

Yeah you are correct, but i am currently working on a .NET 5 application and it won't be upgraded anytime soon.

@JoeRobich
Copy link
Member

JoeRobich commented Mar 30, 2022

@gbubemismith New builds of O# no longer include a minimal Mono and MSBuild (OmniSharp/omnisharp-roslyn#2339). Since you have "omnisharp.path" set to "latest", you are using one of these builds. What version of Mono and MSBuild are installed on your system?

$ mono --version
$ msbuild --version

@gbubemismith
Copy link
Author

  • Mono
    Mono JIT compiler version 6.12.0.122 (2020-02/c621c35ffa0 Wed Feb 10 00:51:43 EST 2021)
    Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:
    SIGSEGV: altstack
    Notification: kqueue
    Architecture: amd64
    Disabled: none
    Misc: softdebug
    Interpreter: yes
    LLVM: yes(610)
    Suspend: hybrid
    GC: sgen (concurrent by default)

  • Msbuild
    Microsoft (R) Build Engine version 16.6.0 for Mono
    Copyright (C) Microsoft Corporation. All rights reserved.

16.6.0.10801%

@JoeRobich
Copy link
Member

@gbubemismith You will need to install a preview build of Mono with a more recent MSBuild (see https://github.com/OmniSharp/omnisharp-vscode#note-about-using-net-5-sdks=) as your version of Mono does not support .NET 5 development. (Download)

The alternative is to set "omnisharp.useModernNet" to true in your VS Code settings. This does require a .NET 6 SDK installation which can be done side-by-side with your .NET 5 SDK.

@amroczeK
Copy link

omnisharp.useModernNet

Thank you, this resolved my issue.

Omnisharp randomly started to stop working for me yesterday, received the same error @gbubemismith was getting.

Im using VSCode 1.65.2, macOS Big Sur v11.6.4

@JoeRobich
Copy link
Member

@amroczeK I imagine you have "omnisharp.path" set to "latest". O# has removed their included Mono and MSBuild 17.x tooling from their nightly builds in favor of using the .NET SDK build of OmniSharp for .NET SDK development. We plan to make "true" the default for "omnisharp.useModernNet". See #5120 for more details.

@nohwnd
Copy link
Member

nohwnd commented Mar 31, 2022

Yeah you are correct, but i am currently working on a .NET 5 application and it's won't be upgraded anytime soon.

FWIW it is generally safe to install a newer SDK and target earlier TFMs from it. For example we use .NET7 x64 SDK to build an app as netcoreapp3.1 for x64, netcoreapp3.1 for x86, net452 for x86, net452 for x64, and netcoreapp2.1 for arm64.

Unless your app is a development tool and has ties to the SDK itself, e.g as omnisharp-roslyn that uses various bits and pieces from the SDK.

@gbubemismith
Copy link
Author

Sorry if I am clear you're saying I can have only .NET 6 sdk installed on my machine and still run a .NET 5 or .NET 3.1 application??

@JoeRobich
Copy link
Member

@gbubemismith Running applications only requires that you have an appropriate .NET runtime installed. You can even publish applications as self-contained apps which do not need a runtime at all.

@MarianaK96
Copy link

@gbubemismith You will need to install a preview build of Mono with a more recent MSBuild (see https://github.com/OmniSharp/omnisharp-vscode#note-about-using-net-5-sdks=) as your version of Mono does not support .NET 5 development. (Download)

The alternative is to set "omnisharp.useModernNet" to true in your VS Code settings. This does require a .NET 6 SDK installation which can be done side-by-side with your .NET 5 SDK.

I have dotnet 6 SDK installed but the second solution here hasn't worked for me. I am also not receiving any errors from Omnisharp. Not sure if it could be due to the project I am working on using dotnet 5?

@JoeRobich
Copy link
Member

@MarianaK96 Can you please open a new issue and provide your Omnisharp log from the VS Code Output pane as well as the output of dotnet --info? Thanks

@UcheIgbokwe
Copy link

UcheIgbokwe commented Apr 6, 2022

I just uninstalled .net 5 and restarted Omnisharp. Below is my error:

` Starting OmniSharp server at 4/6/2022, 4:04:20 PM
Target: /Users/Igbokwe/Projects/AlgorithmMadeEasyV2

OmniSharp server started with .NET 6.0.101
.
Path: /Users/Igbokwe/.vscode/extensions/ms-dotnettools.csharp-1.24.3-darwin-arm64/.omnisharp/1.38.3-beta.33-net6.0/OmniSharp.dll
PID: 1264

Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Users/Igbokwe/.vscode/extensions/ms-dotnettools.csharp-1.24.3-darwin-arm64/.omnisharp/1.38.3-beta.33-net6.0/OmniSharp.dll'. An attempt was made to load a program with an incorrect format.

File name: '/Users/Igbokwe/.vscode/extensions/ms-dotnettools.csharp-1.24.3-darwin-arm64/.omnisharp/1.38.3-beta.33-net6.0/OmniSharp.dll'
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute). `

@JoeRobich
Copy link
Member

@UcheIgbokwe Looks like you have the x64 build of the .NET 6 sdk installed on a M1 Mac. If you install the arm64 build, this should fix your issue.

@UcheIgbokwe
Copy link

@JoeRobich Just switched to the arm64 build and it works fine on vscode.

@gbubemismith
Copy link
Author

gbubemismith commented Apr 7, 2022

@JoeRobich is there a way I can make my cli point to .net 6 path? My cli always points to the x64 path no matter the order in which I install.

Never mind I have sorted it out

@carlosxup
Copy link

carlosxup commented May 31, 2022

Just in case some one else has this problem in Mac M1 Monterrey:
I had my CLI pointing to x64 versions so I downloaded the arm64 version but CLI did not even displayed it.
So I needed to delete my symlink (it was pointing to x64 versions)
$ sudo rm /usr/local/bin/dotnet
and then I needed to create it in the right way:
$ sudo ln -s /usr/local/share/dotnet /usr/local/bin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants