-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
omnisharp-vscode version 1.24.3 does not load on debian (possibly other OS'es) #5147
Comments
In case you encounter this issue, one way to reverting back to a version without this issue present is using a "devcontainer.json" file that specifies which version of the extension you want to use. Here is an example:
|
The root cause for this issue could be similar to the one mentioned here: OmniSharp/omnisharp-roslyn#1421 Once I disable the extension |
Another observation: After omnisharp has started successfully, I can also install the extentions However, if extension This observation applies to version 1.24.1 and 1.24.3 of It appears as if either some files are missing when omnisharp is trying to load roslynator -or- it may be using a wrong path or directory when it attempts to load. Or it is using an outdated and therefore incompatible version of roslynator. The most recent release of roslynator was on 30 Mar 2022 which is quite recent from a time perspective. omnisharp-vscode 1.24.3 was release 02 April 2022. This may have overlapped. |
If the roslynator extension is not loaded by omnisharp but only after omnisharp finished loading, then I can manually install the roslynator extension successfully as well. This observation applies to both docker base images, i.e., But even in that case, to get a clean omnisharp log output the following recipe seem to help:
|
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 |
Adding For reference, this is the exception:
|
@filipw That seems to have done the trick. It also appears to have solve a few other smaller issues. Thank you for the fast response! I'll close this issue for now as it appears to be resolved. In case I run into the same or similar issue I'll submit a new issue. |
If I understand correctly, with the knowledge from #5120, this means that Unity projects are now broken (somewhat faster than announced 😄)? I can fix the error above by switching to modern .NET, but then my Unity projects don't work any more. |
OmniSharp used to have two variants:
The new .NET 6.0 build, which is enabled by setting The other mode (global Mono) is still there and remains the official way of dealing with Unity until Unity moves to .NET 6.0 (or at least to new .NET project format), so that should not be affected. |
Okay, that is good to hear - but is it possible this issue has been closed too quickly in that case? I'm using global mono ( I'm also on (Arch) Linux, so this may be Linux-specific (or rather: non-Windows-specific). EDIT: I have Mono 6.12 installed, as well as mono-msbuild and mono-msbuild-sdkresolver, which are all listed on the Arch wiki as being required, and this also worked fine before the update to 1.24.3. Logs, in case it helps:
EDIT2: I just realized the error is related to Roslynator, and this is a PEBKAC problem. I disabled Roslynator globally but the DLLs were inserted in |
I believe the Roslynator extension manipulates omnisharp.json on install to inject its assemblies into the OminSharp extensions to be loaded, and even when you remove Roslynator, the file would stay modified. But yeah this is external dependency issue in this case. |
Issue Description
Version 1.24.3 of the extension fails to load, throwing an
TypeLoadException
with messageSteps to Reproduce
Use docker base image
mcr.microsoft.com/dotnet/sdk:6.0.201
for the dev container then specify the extension indevcontainer.json
for the dev container. After VS Code has connected to the dev container it attempts to install the extension which fails with aTypeLoadException
.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)
b__1 () [0x0017d] in <1b91b6472b674f53a4fe2ae232ca9859>:0info: 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.IEnumerable
1[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 :0at 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.
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
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
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 withCtrl+.
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:
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.The text was updated successfully, but these errors were encountered: