In the Visual Studio Code editor, with C#, I was getting the following error:
“Failed to run test because OmniSharp server is not running“
This was the error trace:
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 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
After a lot of research, I was able to find a fix for this issue. We need to add the following two settings in VS Code settings file (VSCode >> Preferences >> Settings):
"omnisharp.path": "",
"omnisharp.useModernNet": true
Restarting the VS Code will make the Omnisharp work now.
If you have shifted from x64 to ARM M1 Mac then you will have uninstall the existing VS Code and download the latest VSCode for MAC: https://code.visualstudio.com/download