Omnisharp server startup exception: InvalidCast
See original GitHub issueIssue Description
When starting the OmniSharp server, it encounters a InvalidCastException and cannot start.
Steps to Reproduce
Have .NET Core 2.2 SDK installed, install .NET Core 3.0-preview, then remove .NET Core 3.0-preview, but the issue persists (even after uninstalling and re-installing the Omnisharp plugin). dotnet restore
and dotnet run
both work without issue.
Expected Behavior
Omnisharp server starts without exception.
Actual Behavior
Omnisharp server encounters an exception, and does not start.
Logs
OmniSharp log
Starting OmniSharp server at 9/11/2019, 2:29:46 PM Target: /Users/my-user/path/to/project
OmniSharp server started. Path: /Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/run PID: 5309
Starting OmniSharp on MacOS 10.14.5 (x64)
DotNetPath set to dotnet
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "/Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild/Current/Bin"
MSBUILD_EXE_PATH environment variable set to '/Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
Registered MSBuild instance: StandAlone 15.0 - "/Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild/Current/Bin"
MSBuildExtensionsPath = /Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild
BypassFrameworkInstallChecks = true
CscToolPath = /Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild/Current/Bin/Roslyn
CscToolExe = csc.exe
MSBuildToolsPath = /Users/my-user/.vscode/extensions/ms-vscode.csharp-1.21.2/.omnisharp/1.32.19-beta.25/omnisharp/.msbuild/Current/Bin
TargetFrameworkRootPath = /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/xbuild-frameworks
System.InvalidCastException: Specified cast is not valid.
at Roslyn.Utilities.EventMap.GetRegistries_NoLock[TEventHandler] (System.String eventName) [0x0001b] in <889d2020dcce4567aad80a068551b1d4>:0
at Roslyn.Utilities.EventMap.AddEventHandler[TEventHandler] (System.String eventName, TEventHandler eventHandler) [0x00015] in <889d2020dcce4567aad80a068551b1d4>:0
at Microsoft.CodeAnalysis.Workspace.add_WorkspaceChanged (System.EventHandler1[TEventArgs] value) [0x00000] in <889d2020dcce4567aad80a068551b1d4>:0 at Microsoft.AspNetCore.Razor.OmniSharpPlugin.PrecompiledRazorPageSuppressor..ctor (OmniSharp.OmniSharpWorkspace workspace) [0x0001b] in <8c6f4eb2e16d4051ba80a599aba81c54>:0 at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,System.Composition.Hosting.Core.LifetimeContext,System.Composition.Hosting.Core.CompositionOperation) at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate (System.Int32 sharingId, System.Composition.Hosting.Core.CompositionOperation operation, System.Composition.Hosting.Core.CompositeActivator creator) [0x000a8] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.TypedParts.ActivationFeatures.LifetimeFeature+<>c__DisplayClass1_0.<RewriteActivator>b__0 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x00011] in <9aac21a4a3f24063b2b8b59143acddfc>:0 at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_2
1[TElement].<GetImportManyDescriptor>b__4 (System.Composition.Hosting.Core.ExportDescriptor e) [0x00006] in <8e026c716fc84f38aae28085eaaee9fc>:0
at System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable
1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0
at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_11[TElement].<GetImportManyDescriptor>b__3 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x0002b] in <8e026c716fc84f38aae28085eaaee9fc>:0 at (wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,System.Composition.Hosting.Core.LifetimeContext,System.Composition.Hosting.Core.CompositionOperation) at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate (System.Int32 sharingId, System.Composition.Hosting.Core.CompositionOperation operation, System.Composition.Hosting.Core.CompositeActivator creator) [0x000a8] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.TypedParts.ActivationFeatures.LifetimeFeature+<>c__DisplayClass1_0.<RewriteActivator>b__0 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x00011] in <9aac21a4a3f24063b2b8b59143acddfc>:0 at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_2
1[TElement].<GetImportManyDescriptor>b__4 (System.Composition.Hosting.Core.ExportDescriptor e) [0x00006] in <8e026c716fc84f38aae28085eaaee9fc>:0
at System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () [0x00012] in <28b7381f9e304c3eae9fa66907f89854>:0 at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable
1[T] source) [0x0001f] in <28b7381f9e304c3eae9fa66907f89854>:0
at System.Composition.Hosting.Providers.ImportMany.ImportManyExportDescriptorProvider+<>c__DisplayClass3_11[TElement].<GetImportManyDescriptor>b__3 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x0002b] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.Hosting.Core.CompositionOperation.Run (System.Composition.Hosting.Core.LifetimeContext outermostLifetimeContext, System.Composition.Hosting.Core.CompositeActivator compositionRootActivator) [0x0001c] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.Hosting.Core.LifetimeContext.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x0001d] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.Hosting.CompositionHost.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in <8e026c716fc84f38aae28085eaaee9fc>:0 at System.Composition.CompositionContext.GetExport (System.Composition.Hosting.Core.CompositionContract contract) [0x00000] in <12675e53c8854b48abd187539ce374db>:0 at System.Composition.CompositionContext.GetExports (System.Type exportType, System.String contractName) [0x00023] in <12675e53c8854b48abd187539ce374db>:0 at System.Composition.CompositionContext.GetExports[TExport] (System.String contractName) [0x00000] in <12675e53c8854b48abd187539ce374db>:0 at System.Composition.CompositionContext.GetExports[TExport] () [0x00000] in <12675e53c8854b48abd187539ce374db>:0 at OmniSharp.Stdio.Host.Initialize () [0x0001e] in <3cc12c7c00f344b08c42dfac73970669>: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) [0x00070] in <3cc12c7c00f344b08c42dfac73970669>:0 at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x00138] in <0a1d4b17e42e41ff8dffd9ad6b26ea3a>:0 at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <26e431e77bba4574aea35bb4bb3374a8>: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 <26e431e77bba4574aea35bb4bb3374a8>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <0a1d4b17e42e41ff8dffd9ad6b26ea3a>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <26e431e77bba4574aea35bb4bb3374a8>:0
C# log
Environment information
VSCode version: 1.38.0 C# Extension: 1.21.2
Mono Information
OmniSharp using built-in monoDotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.2.402 Commit: c7f2f96116Runtime 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.402/
Host (useful for support): Version: 3.0.0-preview9-19423-09 Commit: 2be172345a
.NET Core SDKs installed: 2.0.0 [/usr/local/share/dotnet/sdk] 2.1.3 [/usr/local/share/dotnet/sdk] 2.1.302 [/usr/local/share/dotnet/sdk] 2.1.403 [/usr/local/share/dotnet/sdk] 2.2.103 [/usr/local/share/dotnet/sdk] 2.2.104 [/usr/local/share/dotnet/sdk] 2.2.402 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [/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 |
---|---|---|
auto-rename-tag | formulahendry | 0.1.0 |
code-spell-checker | streetsidesoftware | 1.7.18 |
csharp | ms-vscode | 1.21.2 |
npm-intellisense | christian-kohler | 1.3.0 |
prettier-vscode | esbenp | 2.2.2 |
rainbow-csv | mechatroner | 1.3.1 |
relativepath | john681611 | 0.1.2 |
sublime-keybindings | ms-vscode | 4.0.3 |
vscode-eslint | dbaeumer | 1.9.1 |
vscode-icons | vscode-icons-team | 9.3.0 |
vscode-nuget-package-manager | jmrog | 1.1.6 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
or try removing “omnisharp.path”: “latest” from the settings
@filipw thanks! that must’ve done it, i saw that beta25 was specified in my settings.json, as soon as I deleted that, it asked if I wanted to restart O#, I did, and it’s back to working again.
Thanks!