Omnisharp-vscode: System.TypeLoadException

Created on 20 Jul 2019  路  12Comments  路  Source: OmniSharp/omnisharp-vscode

Issue Description

System.TypeLoadException: Could not load type of field 'Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser:_context' (1) 

Steps to Reproduce

omnisharp instantly reports the issue when starting vscode or restarting omnisharp

OmniSharp log

Starting OmniSharp server at 2019-07-20, 11:07:12 a.m.
    Target: correct_path_to_sln (redacted)

OmniSharp server started with Mono 5.18.1.
    Path: /Users/keeganstothert/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/OmniSharp.exe
    PID: 95137

System.TypeLoadException: Could not load type of field 'Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser:_context' (1) due to: Could not resolve type with token 01000018 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.Stack`1 member:(null)
  at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load (System.Boolean reload) [0x0010b] in <5b0219d367fd4fd68bb5d8e979bb16b3>:0 
  at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load () [0x00000] in <5b0219d367fd4fd68bb5d8e979bb16b3>:0 
  at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor (System.Collections.Generic.IList`1[T] providers) [0x0003b] in <c58a7bdd3f5a468aa1ce25bba6f36889>:0 
  at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build () [0x0003c] in <c58a7bdd3f5a468aa1ce25bba6f36889>:0 
  at OmniSharp.ConfigurationBuilder.Build () [0x00073] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x000bc] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 

[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

C# log

empty

Environment information

VSCode version: 1.36.1
C# Extension: 1.21.0

Mono Information
OmniSharp using global mono :5.18.1

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 2.2.301
Commit: 70d6be0814

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

Host (useful for support):
Version: 3.0.0-preview6-27804-01
Commit: fdf81c6faf

.NET Core SDKs installed:
2.2.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview6-27804-01 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download


Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|atom-keybindings|ms-vscode|3.0.6|
|code-settings-sync|Shan|3.4.0|
|cpptools|ms-vscode|0.24.0|
|csharp|ms-vscode|1.21.0|
|es7-react-js-snippets|dsznajder|2.3.0|
|hide-gitignored|npxms|1.0.1|
|markdown-all-in-one|yzhang|2.4.0|
|Material-theme|zhuangtongfa|2.26.0|
|msbuild-project-tools|tintoy|0.2.55|
|prettier-vscode|esbenp|1.9.0|
|python|ms-python|2019.6.24221|
|restructuredtext|lextudio|113.0.0|
|rust|rust-lang|0.6.1|
|unity-tools|Tobiah|1.1.1|
|vscode-apollo|apollographql|1.7.4|
|vscode-arduino|vsciot-vscode|0.2.27|
|vscode-eslint|dbaeumer|1.9.0|
|vscode-great-icons|emmanuelbeziat|2.1.47|
|vscode-styled-jsx|blanu|1.5.0|
|vscode-theme-onelight|akamud|2.1.0|
|vscode-typescript-tslint-plugin|ms-vscode|1.2.2|
|write-good-linter|travisthetechie|0.1.1|;

I have tried every step in all similar issues. I have uninstalled and reinstalled mono, unity, dotnet, and vscode. i've had similar issues with omnisharp in the past and was able to resolve them with some combination of the above and messing with "omnisharp.path": "latest", but this time nothing is working

Most helpful comment

downgrading my c# extension to 1.20.0 fixed a similar issue for me on OSX..... I was getting an error around System.TypeInitializationException: The type initializer for 'Microsoft.Build.Shared.NativeMethodsShared' threw an exception.

if it seems related enough to this I can re-upgrade and then capture the entire error message but I didn't have to touch anything w/ mono directly to resolve. just downgrade from 1.20.1 -> 1.20.0

All 12 comments

can you please share the complete OmniSharp log?

ah it's there already, sorry. can you try installing Mono 5.20?

Starting OmniSharp server at 2019-07-20, 4:11:48 p.m.
    Target: /Users/keeganstothert/Documents/projects/games/cuphead/cuphead.sln

OmniSharp server started with Mono 5.20.1.
    Path: /Users/keeganstothert/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/OmniSharp.exe
    PID: 99904

System.TypeLoadException: Could not load type of field 'Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser:_context' (1) due to: Could not resolve type with token 01000018 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.Stack`1 member:(null)
  at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load (System.Boolean reload) [0x0010b] in <5b0219d367fd4fd68bb5d8e979bb16b3>:0 
  at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load () [0x00000] in <5b0219d367fd4fd68bb5d8e979bb16b3>:0 
  at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor (System.Collections.Generic.IList`1[T] providers) [0x0003b] in <c58a7bdd3f5a468aa1ce25bba6f36889>:0 
  at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build () [0x0003c] in <c58a7bdd3f5a468aa1ce25bba6f36889>:0 
  at OmniSharp.ConfigurationBuilder.Build () [0x00073] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x000bc] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 

here's the new output...looks identical except for version 5.20.1. I've also tried 6.0 which just came out. Same issue

what happens when you set "omnisharp.useGlobalMono": "never"?
also one other thing to try would be to completely remove extension folder /Users/keeganstothert/.vscode/extensions/ms-vscode.csharp-1.21.0/ and reinstall again. we've seen similar issues when the downloaded omnisharp got corrupt

yea i tried both those solutions again (they were offered as solutions in similar issues and I've tried them all). I get the exact same error in the output

it really sounds like a mono bug then.

can you navigate to ~/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp and try running mono OmniSharp.exe or to ~/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34. and try running run?

with mono Omnisharp.exe i get this output

System.TypeInitializationException: The type initializer for 'OmniSharp.MSBuild.Discovery.MSBuildLocator' threw an exception. ---> System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not load type of field 'System.Collections.Immutable.SortedInt32KeyNode`1+Enumerator[TValue]:s_enumeratingStacks' (0) due to: Could not resolve type with token 01000026 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.Stack`1 member:(null) assembly:/Users/keeganstothert/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/System.Collections.Immutable.dll type:Enumerator member:(null)
  at System.Collections.Immutable.ImmutableHashSet`1[T].GetEnumerator () [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableExtensions.GetEnumerableDisposable[T,TEnumerator] (System.Collections.Generic.IEnumerable`1[T] enumerable) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] other, System.Collections.Immutable.ImmutableHashSet`1+MutationInput[T] origin) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] items, System.Boolean avoidWithComparer) [0x00034] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].WithComparer (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer) [0x0001c] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet.Create[T] (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer, T[] items) [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at OmniSharp.MSBuild.Discovery.MSBuildLocator..cctor () [0x00005] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
   --- End of inner exception stack trace ---
  at OmniSharp.CompositionHostBuilder+<>c__DisplayClass6_0.<CreateDefaultServiceProvider>b__0 (System.IServiceProvider sp) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory (Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryCallSite factoryCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00006] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x0003a] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped (Microsoft.Extensions.DependencyInjection.ServiceLookup.ScopedCallSite scopedCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0002d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton (Microsoft.Extensions.DependencyInjection.ServiceLookup.SingletonCallSite singletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0000d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x00072] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.<RealizeService>b__0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0003e] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00032] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00008] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, System.Type serviceType) [0x00034] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T] (System.IServiceProvider provider) [0x0000e] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at OmniSharp.CompositionHostBuilder.Build () [0x00082] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Host..ctor (System.IO.TextReader input, OmniSharp.Services.ISharedTextWriter writer, OmniSharp.IOmniSharpEnvironment environment, System.IServiceProvider serviceProvider, OmniSharp.CompositionHostBuilder compositionHostBuilder, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Threading.CancellationTokenSource cancellationTokenSource) [0x00057] in <7c5553f153394952b6183930a12b0c7a>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x00138] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 

with run the output is

System.TypeInitializationException: The type initializer for 'OmniSharp.MSBuild.Discovery.MSBuildLocator' threw an exception. ---> System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not load type of field 'System.Collections.Immutable.SortedInt32KeyNode`1+Enumerator[TValue]:s_enumeratingStacks' (0) due to: Could not resolve type with token 01000026 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.Stack`1 member:(null) assembly:/Users/keeganstothert/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/System.Collections.Immutable.dll type:Enumerator member:(null)
  at System.Collections.Immutable.ImmutableHashSet`1[T].GetEnumerator () [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableExtensions.GetEnumerableDisposable[T,TEnumerator] (System.Collections.Generic.IEnumerable`1[T] enumerable) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] other, System.Collections.Immutable.ImmutableHashSet`1+MutationInput[T] origin) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] items, System.Boolean avoidWithComparer) [0x00034] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].WithComparer (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer) [0x0001c] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet.Create[T] (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer, T[] items) [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at OmniSharp.MSBuild.Discovery.MSBuildLocator..cctor () [0x00005] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
   --- End of inner exception stack trace ---
  at OmniSharp.CompositionHostBuilder+<>c__DisplayClass6_0.<CreateDefaultServiceProvider>b__0 (System.IServiceProvider sp) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory (Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryCallSite factoryCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00006] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x0003a] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped (Microsoft.Extensions.DependencyInjection.ServiceLookup.ScopedCallSite scopedCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0002d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton (Microsoft.Extensions.DependencyInjection.ServiceLookup.SingletonCallSite singletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0000d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x00072] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.<RealizeService>b__0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0003e] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00032] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00008] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, System.Type serviceType) [0x00034] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T] (System.IServiceProvider provider) [0x0000e] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at OmniSharp.CompositionHostBuilder.Build () [0x00082] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Host..ctor (System.IO.TextReader input, OmniSharp.Services.ISharedTextWriter writer, OmniSharp.IOmniSharpEnvironment environment, System.IServiceProvider serviceProvider, OmniSharp.CompositionHostBuilder compositionHostBuilder, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Threading.CancellationTokenSource cancellationTokenSource) [0x00057] in <7c5553f153394952b6183930a12b0c7a>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x00138] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <8c5dac6e15f8406f96c0166019f5cce3>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <2a5906ca9ef7486cb9ec80794c73eb10>:0 
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...16 completed.

[Process completed]

and i just discovered i can't run msbuild myproj.sln the output for that is

Microsoft (R) Build Engine version 16.0.451+gdcd570aa77 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2019-07-21 11:35:19 AM.

Build FAILED.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.04
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.TypeLoadException: Could not load type of field 'Microsoft.Build.BackEnd.SchedulingPlan:_configIdToPaths' (4) due to: Could not resolve type with token 0100004a from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Collections.Generic.Stack`1 member:(null)
  at Microsoft.Build.Execution.BuildManager.AddNewConfiguration (Microsoft.Build.BackEnd.BuildRequestConfiguration unresolvedConfiguration) [0x0000c] in <f6654e9bc00948f485cff24fa8be2a84>:0 
  at Microsoft.Build.Execution.BuildManager.ResolveConfiguration (Microsoft.Build.BackEnd.BuildRequestConfiguration unresolvedConfiguration, Microsoft.Build.BackEnd.BuildRequestConfiguration matchingConfigurationFromCache, System.Boolean replaceProjectInstance) [0x0001b] in <f6654e9bc00948f485cff24fa8be2a84>:0 
  at Microsoft.Build.Execution.BuildManager.ExecuteSubmission (Microsoft.Build.Execution.BuildSubmission submission, System.Boolean allowMainThreadBuild) [0x002f2] in <f6654e9bc00948f485cff24fa8be2a84>:0 
  at Microsoft.Build.Execution.BuildSubmission.ExecuteAsync (Microsoft.Build.Execution.BuildSubmissionCompleteCallback callback, System.Object context, System.Boolean allowMainThreadBuild) [0x00027] in <f6654e9bc00948f485cff24fa8be2a84>:0 
  at Microsoft.Build.Execution.BuildSubmission.Execute () [0x00018] in <f6654e9bc00948f485cff24fa8be2a84>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.ExecuteBuild (Microsoft.Build.Execution.BuildManager buildManager, Microsoft.Build.Execution.BuildRequestData request) [0x0003c] in <a9b784c8cef94b588454920fadc4eff8>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.BuildProject (System.String projectFile, System.String[] targets, System.String toolsVersion, System.Collections.Generic.Dictionary`2[TKey,TValue] globalProperties, System.Collections.Generic.Dictionary`2[TKey,TValue] restoreProperties, Microsoft.Build.Framework.ILogger[] loggers, Microsoft.Build.Framework.LoggerVerbosity verbosity, Microsoft.Build.CommandLine.DistributedLoggerRecord[] distributedLoggerRecords, System.Int32 cpuCount, System.Boolean enableNodeReuse, System.IO.TextWriter preprocessWriter, System.Boolean detailedSummary, System.Collections.Generic.ISet`1[T] warningsAsErrors, System.Collections.Generic.ISet`1[T] warningsAsMessages, System.Boolean enableRestore, Microsoft.Build.Logging.ProfilerLogger profilerLogger, System.Boolean enableProfiler, System.Boolean interactive, System.Boolean isolateProjects, System.Boolean graphBuild, System.String[] inputResultsCaches, System.String outputResultsCache) [0x00477] in <a9b784c8cef94b588454920fadc4eff8>:0 

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.TypeLoadException: Could not load type of field 'Microsoft.Build.BackEnd.SchedulingPlan:_configIdToPaths' (4) due to: Could not resolve type with token 0100004a from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Collections.Generic.Stack`1 member:(null)
  at Microsoft.Build.CommandLine.MSBuildApp.BuildProject (System.String projectFile, System.String[] targets, System.String toolsVersion, System.Collections.Generic.Dictionary`2[TKey,TValue] globalProperties, System.Collections.Generic.Dictionary`2[TKey,TValue] restoreProperties, Microsoft.Build.Framework.ILogger[] loggers, Microsoft.Build.Framework.LoggerVerbosity verbosity, Microsoft.Build.CommandLine.DistributedLoggerRecord[] distributedLoggerRecords, System.Int32 cpuCount, System.Boolean enableNodeReuse, System.IO.TextWriter preprocessWriter, System.Boolean detailedSummary, System.Collections.Generic.ISet`1[T] warningsAsErrors, System.Collections.Generic.ISet`1[T] warningsAsMessages, System.Boolean enableRestore, Microsoft.Build.Logging.ProfilerLogger profilerLogger, System.Boolean enableProfiler, System.Boolean interactive, System.Boolean isolateProjects, System.Boolean graphBuild, System.String[] inputResultsCaches, System.String outputResultsCache) [0x005a1] in <a9b784c8cef94b588454920fadc4eff8>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x0019d] in <a9b784c8cef94b588454920fadc4eff8>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type of field 'Microsoft.Build.BackEnd.SchedulingPlan:_configIdToPaths' (4) due to: Could not resolve type with token 0100004a from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') assembly:System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.Collections.Generic.Stack`1 member:(null)
  at Microsoft.Build.CommandLine.MSBuildApp.BuildProject (System.String projectFile, System.String[] targets, System.String toolsVersion, System.Collections.Generic.Dictionary`2[TKey,TValue] globalProperties, System.Collections.Generic.Dictionary`2[TKey,TValue] restoreProperties, Microsoft.Build.Framework.ILogger[] loggers, Microsoft.Build.Framework.LoggerVerbosity verbosity, Microsoft.Build.CommandLine.DistributedLoggerRecord[] distributedLoggerRecords, System.Int32 cpuCount, System.Boolean enableNodeReuse, System.IO.TextWriter preprocessWriter, System.Boolean detailedSummary, System.Collections.Generic.ISet`1[T] warningsAsErrors, System.Collections.Generic.ISet`1[T] warningsAsMessages, System.Boolean enableRestore, Microsoft.Build.Logging.ProfilerLogger profilerLogger, System.Boolean enableProfiler, System.Boolean interactive, System.Boolean isolateProjects, System.Boolean graphBuild, System.String[] inputResultsCaches, System.String outputResultsCache) [0x005a1] in <a9b784c8cef94b588454920fadc4eff8>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Execute (System.String commandLine) [0x00415] in <a9b784c8cef94b588454920fadc4eff8>:0 
  at Microsoft.Build.CommandLine.MSBuildApp.Main () [0x00028] in <a9b784c8cef94b588454920fadc4eff8>:0

so i found a solution that works for me.

i uninstalled mono

sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands

then i installed the latest mono through brew (version 6)

it still didn't work though and i wasn't able to confirm installation with mono --version

so i added export PATH=$PATH:/usr/local/Cellar/mono/6.0.0.313/bin to my .bash_profile
that got rid of the initial error but to get omnisharp to actually provide intellisense to my unity project I had to run msbuild myproject.sln

that works for now!

downgrading my c# extension to 1.20.0 fixed a similar issue for me on OSX..... I was getting an error around System.TypeInitializationException: The type initializer for 'Microsoft.Build.Shared.NativeMethodsShared' threw an exception.

if it seems related enough to this I can re-upgrade and then capture the entire error message but I didn't have to touch anything w/ mono directly to resolve. just downgrade from 1.20.1 -> 1.20.0

Facing same error

Starting OmniSharp server at 3/8/2019, 5:26:12 PM
    Target: *************

OmniSharp server started with Mono 5.20.1.
    Path: /home/pramod/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/OmniSharp.exe
    PID: 5703

System.TypeInitializationException: The type initializer for 'OmniSharp.MSBuild.Discovery.MSBuildLocator' threw an exception. ---> System.TypeLoadException: Could not find method '.ctor' due to a type load error: Could not load type of field 'System.Collections.Immutable.SortedInt32KeyNode`1+Enumerator[TValue]:s_enumeratingStacks' (0) due to: Could not resolve type with token 01000026 from typeref (expected class 'System.Collections.Generic.Stack`1' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Collections.Generic.Stack`1 member:(null) assembly:/home/pramod/.vscode/extensions/ms-vscode.csharp-1.21.0/.omnisharp/1.34.0/omnisharp/System.Collections.Immutable.dll type:Enumerator member:(null)
  at System.Collections.Immutable.ImmutableHashSet`1[T].GetEnumerator () [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableExtensions.GetEnumerableDisposable[T,TEnumerator] (System.Collections.Generic.IEnumerable`1[T] enumerable) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] other, System.Collections.Immutable.ImmutableHashSet`1+MutationInput[T] origin) [0x00015] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].Union (System.Collections.Generic.IEnumerable`1[T] items, System.Boolean avoidWithComparer) [0x00034] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet`1[T].WithComparer (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer) [0x0001c] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at System.Collections.Immutable.ImmutableHashSet.Create[T] (System.Collections.Generic.IEqualityComparer`1[T] equalityComparer, T[] items) [0x00000] in <6518d0e60ca84f6b915c07341a031a32>:0 
  at OmniSharp.MSBuild.Discovery.MSBuildLocator..cctor () [0x00005] in <3550ddd66d4043539c45cc4b41dec9dc>:0 
   --- End of inner exception stack trace ---
  at OmniSharp.CompositionHostBuilder+<>c__DisplayClass6_0.<CreateDefaultServiceProvider>b__0 (System.IServiceProvider sp) [0x0001c] in <3550ddd66d4043539c45cc4b41dec9dc>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory (Microsoft.Extensions.DependencyInjection.ServiceLookup.FactoryCallSite factoryCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00006] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x0003a] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped (Microsoft.Extensions.DependencyInjection.ServiceLookup.ScopedCallSite scopedCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0002d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton (Microsoft.Extensions.DependencyInjection.ServiceLookup.SingletonCallSite singletonCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0000d] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[TArgument,TResult].VisitCallSite (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, TArgument argument) [0x00072] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve (Microsoft.Extensions.DependencyInjection.ServiceLookup.IServiceCallSite callSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine+<>c__DisplayClass1_0.<RealizeService>b__0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope scope) [0x0003e] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope serviceProviderEngineScope) [0x00032] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService (System.Type serviceType) [0x00008] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService (System.Type serviceType) [0x00000] in <824e19d8b53a48d8867d85feb58265d3>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, System.Type serviceType) [0x00034] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T] (System.IServiceProvider provider) [0x0000e] in <4b47b422bc4c4615bbdebe1df9b21b0d>:0 
  at OmniSharp.CompositionHostBuilder.Build () [0x00082] in <3550ddd66d4043539c45cc4b41dec9dc>:0 
  at OmniSharp.Stdio.Host..ctor (System.IO.TextReader input, OmniSharp.Services.ISharedTextWriter writer, OmniSharp.IOmniSharpEnvironment environment, System.IServiceProvider serviceProvider, OmniSharp.CompositionHostBuilder compositionHostBuilder, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Threading.CancellationTokenSource cancellationTokenSource) [0x00057] in <9d7bd3e1598f4afe8d6ee99159811c4c>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x00138] in <5e7b0c1479c34220a9a8ec708a4cc365>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <3550ddd66d4043539c45cc4b41dec9dc>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <3550ddd66d4043539c45cc4b41dec9dc>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <5e7b0c1479c34220a9a8ec708a4cc365>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <3550ddd66d4043539c45cc4b41dec9dc>:0 

[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).
Was this page helpful?
0 / 5 - 0 ratings