vscode-csharp: Omnisharp won't start or generate assets in vs code mac m1

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:<unknown assembly> type:<unknown 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 <b81453133ee74092816142afbffb5d49>:0 at OmniSharp.Stdio.StdioCommandLineApplication.get_Encoding () [0x00000] in <ff89c28654c64c08be0af235972b4254>:0 at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x00000] in <4061e52126604f67b6d455853ab7baf7>:0 at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.<OnExecute>b__0 () [0x0000b] in <b81453133ee74092816142afbffb5d49>:0 at McMaster.Extensions.CommandLineUtils.CommandLineApplication+<>c__DisplayClass146_0.<OnExecute>b__0 (System.Threading.CancellationToken _) [0x00000] in <abe0fc6797a94a73931eea5cecaffd78>:0 at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync (System.String[] args, System.Threading.CancellationToken cancellationToken) [0x000bf] in <abe0fc6797a94a73931eea5cecaffd78>:0 at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00016] in <abe0fc6797a94a73931eea5cecaffd78>:0 at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x00081] in <b81453133ee74092816142afbffb5d49>:0 at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <4061e52126604f67b6d455853ab7baf7>:0 at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <b81453133ee74092816142afbffb5d49>: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:<unknown assembly> type:<unknown type> member:(null)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

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/

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

@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.

@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

@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.