omnisharp-vscode version 1.24.3 does not load on debian (possibly other OS'es)
See original GitHub issueIssue Description
Version 1.24.3 of the extension fails to load, throwing an TypeLoadException
with message
Could not load type of field ‘Roslynator.Host.Mef.MefHostServices:_compositionContext’ (2) due to: Could not load file or assembly ‘System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. at (wrapper managed-to-native) System.RuntimeType.GetPropertiesByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,System.RuntimeType/MemberListType) … more stack frames in OmniSharp log below
Steps to Reproduce
Use docker base image mcr.microsoft.com/dotnet/sdk:6.0.201
for the dev container then specify the extension in devcontainer.json
for the dev container. After VS Code has connected to the dev container it attempts to install the extension which fails with a TypeLoadException
.
Using the docker base image with the .NET SDK ensures that no other .NET SDKs or .NET runtimes are installed in the environment. For investigation and/or testing, I believe this could be critical.
Expected Behavior
Version 1.24.3 of the extension loads without exception
Actual Behavior
Version 1.24.3 throws TypeLoadException when being installed/loaded by VS Code. All functionality is broken, in particular code actions.
Logs
OmniSharp log
OmniSharp server started. Path: /home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/run PID: 1700
Starting OmniSharp on debian 11.0 (x64)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
Using the 'dotnet' on the PATH.
DotNetPath set to dotnet
Located 1 MSBuild instance(s)
1: StandAlone 17.1.1 - "/home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild/Current/Bin"
MSBUILD_EXE_PATH environment variable set to '/home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
Registered MSBuild instance: StandAlone 17.1.1 - "/home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/dev/.vscode-server/extensions/ms-dotnettools.csharp-1.24.3-linux-x64/.omnisharp/1.38.2/omnisharp/.msbuild
System.TypeLoadException: Could not load type of field ‘Roslynator.Host.Mef.MefHostServices:_compositionContext’ (2) due to: Could not load file or assembly ‘System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies.
at (wrapper managed-to-native) System.RuntimeType.GetPropertiesByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,System.RuntimeType/MemberListType)
at System.RuntimeType.GetPropertiesByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.RuntimeType+MemberListType listType, System.RuntimeType reflectedType) [0x0001b] in <533173d24dae460899d2b10975534bb0>:0
at System.RuntimeType.GetPropertyCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Type[] types, System.Boolean allowPrefixLookup) [0x00010] in <533173d24dae460899d2b10975534bb0>:0
at System.RuntimeType.GetProperties (System.Reflection.BindingFlags bindingAttr) [0x00000] in <533173d24dae460899d2b10975534bb0>:0
at System.Reflection.RuntimeReflectionExtensions.GetRuntimeProperties (System.Type type) [0x00014] in <533173d24dae460899d2b10975534bb0>:0
at System.Composition.TypedParts.Discovery.TypeInspector+<DiscoverPropertyExports>d__7.MoveNext () [0x00037] in <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.TypedParts.Discovery.TypeInspector+<DiscoverExports>d__5.MoveNext () [0x000db] in <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.TypedParts.Discovery.TypeInspector.InspectTypeForPart (System.Reflection.TypeInfo type, System.Composition.TypedParts.Discovery.DiscoveredPart& part) [0x00061] in <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.TypedParts.TypedPartExportDescriptorProvider…ctor (System.Collections.Generic.IEnumerable1[T] types, System.Composition.Convention.AttributedModelProvider attributeContext) [0x00037] in <2d4bd81b7fea479cb0a52f844b6edf97>:0 at System.Composition.Hosting.ContainerConfiguration.CreateContainer () [0x00042] in <2d4bd81b7fea479cb0a52f844b6edf97>:0 at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create (System.Collections.Generic.IEnumerable
1[T] assemblies) [0x00031] in <f78fde32b7b244ca95ad9f75f5377ae7>:0
at OmniSharp.HostServicesAggregator.CreateHostServices () [0x00000] in <407751de6f434a52aa536ffcf396059d>:0
at OmniSharp.OmniSharpWorkspace…ctor (OmniSharp.HostServicesAggregator aggregator, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, OmniSharp.FileWatching.IFileSystemWatcher fileSystemWatcher) [0x00046] in <407751de6f434a52aa536ffcf396059d>: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.TypedParts.ActivationFeatures.DisposalFeature+<>c__DisplayClass0_0.<RewriteActivator>b__0 (System.Composition.Hosting.Core.LifetimeContext c, System.Composition.Hosting.Core.CompositionOperation o) [0x00000] in <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.Hosting.Core.LifetimeContext.GetOrCreate (System.Int32 sharingId, System.Composition.Hosting.Core.CompositionOperation operation, System.Composition.Hosting.Core.CompositeActivator creator) [0x000a8] in <db7a9e9ce8f2483abd2dba005db8e856>: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 <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.Hosting.Core.CompositionOperation.Run (System.Composition.Hosting.Core.LifetimeContext outermostLifetimeContext, System.Composition.Hosting.Core.CompositeActivator compositionRootActivator) [0x00022] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.Core.LifetimeContext.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x0001d] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.Hosting.CompositionHost.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in <db7a9e9ce8f2483abd2dba005db8e856>:0
at System.Composition.CompositionContext.GetExport (System.Composition.Hosting.Core.CompositionContract contract) [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExport (System.Type exportType, System.String contractName) [0x00008] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExport[TExport] (System.String contractName) [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at System.Composition.CompositionContext.GetExport[TExport] () [0x00000] in <9222e906419e4f47bc57ced5ad91678c>:0
at OmniSharp.Stdio.Host.Initialize () [0x0000d] in <2584067dfcea42a69c19a025cfbc4799>: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) [0x0007b] in <2584067dfcea42a69c19a025cfbc4799>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x0017d] in <1b91b6472b674f53a4fe2ae232ca9859>:0
at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.<OnExecute>b__0 () [0x0000b] in <3d93fabea6954f4ba147450b0cf4332a>: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 <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <1b91b6472b674f53a4fe2ae232ca9859>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <3d93fabea6954f4ba147450b0cf4332a>:0
C# log
Environment information
VSCode version: 1.66.0 C# Extension: 1.24.3
Mono Information
OmniSharp using built-in monoDotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06Runtime Environment: OS Name: debian OS Version: 11 OS Platform: Linux RID: debian.11-x64 Base Path: /usr/share/dotnet/sdk/6.0.201/
Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91
.NET SDKs installed: 6.0.201 [/usr/share/dotnet/sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions
Extension | Author | Version |
---|---|---|
csharp | ms-dotnettools | 1.24.3 |
docomment | k–kato | 0.1.30 |
dotnet-test-explorer | formulahendry | 0.7.7 |
EditorConfig | EditorConfig | 0.16.4 |
gitlens | eamodio | 12.0.5 |
markdown-preview-enhanced | shd101wyy | 0.6.2 |
powershell | ms-vscode | 2021.12.0 |
roslynator | josefpihrt-vscode | 4.1.0 |
vscode-solution-explorer | fernandoescolar | 0.4.5 |
Additional Information/Observations
As a result of this extension not loading the C# related features no longer work. For example F2
to rename an identifier does not work. Selecting any element then trying code actions with Ctrl+.
results in message “No code actions available”.
When I revert to version 1.24.1 of this extensions all works fine. Also checked version 1.24.2 which shows the same problem. Based on my experiments it appears as if this issue was absent in version 1.24.1 and introduced with version 1.24.2.
More details about my set up:
- Windows 10 Pro version 10.0.19044 Build 1044
- WSL2 with distro Ubuntu 20.04
- Docker Desktop version 4.3.2
- Dev container with base image
mcr.microsoft.com/dotnet/sdk:6.0.201
I also tested with base image mcr.microsoft.com/dotnet/sdk:6.0.102
. The observation remains the same.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
This manifests itself, I assume, only on the embedded Mono variant of OmniSharp. It is deprecated and will be removed in the next release.
Things should work correctly on the .NET 6.0 build of OmniSharp which you can enable by setting
"omnisharp.useModernNet":true
Adding
"OmniSharp.useModenNet": true
also resolved an exception on macOS that completely broke OmniSharp at startup.For reference, this is the exception: