Skip to content

omnisharp-vscode version 1.24.3 does not load on debian (possibly other OS'es) #5147

Closed

Description

Issue 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

Starting OmniSharp server at 4/2/2022, 9:12:28 PM Target: /src/Backend.sln

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)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
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"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
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'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
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+d__7.MoveNext () [0x00037] in <2d4bd81b7fea479cb0a52f844b6edf97>:0
at System.Composition.TypedParts.Discovery.TypeInspector+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.IEnumerable1[T] assemblies) [0x00031] in :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.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 :0
at System.Composition.TypedParts.ActivationFeatures.LifetimeFeature+<>c__DisplayClass1_0.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 :0
at System.Composition.Hosting.Core.LifetimeContext.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x0001d] in :0
at System.Composition.Hosting.CompositionHost.TryGetExport (System.Composition.Hosting.Core.CompositionContract contract, System.Object& export) [0x00000] in :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.

b__1 () [0x0017d] in <1b91b6472b674f53a4fe2ae232ca9859>:0
at OmniSharp.CommandLineApplication+<>c__DisplayClass12_0.b__0 () [0x0000b] in <3d93fabea6954f4ba147450b0cf4332a>:0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication+<>c__DisplayClass146_0.b__0 (System.Threading.CancellationToken _) [0x00000] in :0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync (System.String[] args, System.Threading.CancellationToken cancellationToken) [0x000bf] in :0
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00016] in :0
at OmniSharp.CommandLineApplication.Execute (System.String[] args) [0x00081] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.b__0 () [0x00028] in <1b91b6472b674f53a4fe2ae232ca9859>:0
at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <3d93fabea6954f4ba147450b0cf4332a>:0

C# log

Post the output from Output-->C# here: The C# log is empty, no output

Environment information

VSCode version: 1.66.0
C# Extension: 1.24.3

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions