Omnisharp-vscode: System.TypeLoadException on Linux (Linux Mint 19)

Created on 16 Sep 2018  路  11Comments  路  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:

SDK .NET Core (refl茅tant tous les global.json)聽:
 Version:   2.1.402
 Commit:    3599f217f4

Environnement d'ex茅cution聽:
 OS Name:     linuxmint
 OS Version:  19
 OS Platform: Linux
 RID:         linuxmint.19-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.402/

Host (useful for support):
  Version: 2.1.4
  Commit:  85255dde3e

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

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

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

VS Code version:
(I guess this is code --version?)

1.27.2
f46c4c469d6e6d8c46f268d1553c5dc4b475840f
x64

C# Extension version:
1.16.1

Steps to reproduce

  • Launch VSCode in an Unity project (using Unity)
  • Watch the console open and immediately crash the OmniSharp server

Expected behavior

I expect to have IntelliSense and everything that comes with the extension.

Actual behavior

As the server crashes, nothing is added to the standard VSCode.

Additional informations

Here is the full log, using trace logging level:

Starting OmniSharp server at 2018-9-16 21:40:01
    Target: /home/$USER/Sources/Unity/Space Shooter/Space Shooter.sln

OmniSharp server started with Mono 5.14.0.
    Path: /home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/OmniSharp.exe
    PID: 25648

System.TypeLoadException: Could not load type of field 'McMaster.Extensions.CommandLineUtils.CommandLineApplication:_validationErrorHandler' (36) due to: Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  at OmniSharp.Stdio.StdioCommandLineApplication..ctor () [0x00000] in <e2653a02ab1f423abb805f2353ec9507>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00006] in <9671bf457f144c419fb0cdee3ca10088>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <48aa3fb56cea4bd5ab9bfdf1170dd033>:0 
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

I am using the latest Mono and .NET Core, and everything is up-to-date. I also tried reinstalling the .NET Core.
I also tried moving the ~/.vscode folder to an other name and deleting the ~/.omnisharp folder too (as suggested in #2489).
I tried looking into the other issues, but no solution worked for me.

Needs More Info

Most helpful comment

I experienced the same issue on Ubuntu 16.04. I had monoruntime package installed. For me, setting omnisharp.useGlobalMono to Never solved the issue.

All 11 comments

@rajdakin Can you share the output of mono --version? What have you set the option omnisharp.useGlobalMono to?

Here is mono --version:

Mono JIT compiler version 5.14.0.177 (tarball Mon Aug  6 09:07:45 UTC 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    Interpreter:   yes
    LLVM:          yes(3.6.0svn-mono-/)
    GC:            sgen (concurrent by default)

I didn't change anything in the config, so omnisharp.useGlobalMono is currently set to auto. By changing it to always, nothing changes.

By changing it to never, however, I get a different result, probably because it didn't find Mono. This is the last lines in information logging level:

/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj

@rajdakin: Could you share your full OmniSharp Log for that last case?

Here it is, in trace logging level:

Starting OmniSharp server at 2018-9-19 11:51:33
    Target: /home/$USER/Sources/Unity/Space Shooter/Space Shooter.sln

OmniSharp server started.
    Path: /home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/run
    PID: 30210

锘縖info]: OmniSharp.Stdio.Host
        Starting OmniSharp on linuxmint 19.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild
            BypassFrameworkInstallChecks = true
            CscToolPath = /home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/$USER/Sources/Unity/Space Shooter'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/home/$USER/Sources/Unity/Space Shooter/Space Shooter.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/$USER/Sources/Unity/Space Shooter'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/home/$USER/Sources/Unity/Space Shooter' on host 24589.
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj'.
/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj
/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
        The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj'.
/home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj
/home/$USER/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1195,5): Error: The reference assemblies for framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: /home/$USER/Sources/Unity/Space Shooter/Assembly-CSharp-Editor.csproj

https://github.com/OmniSharp/omnisharp-vscode/issues/2509#issuecomment-420318250

Ghostbird's solution worked for me!
Running Linux Mint (Cinnamon)

Well, at least the extension's status icon switched to green... Before exiting as the server timeout (crash).
It still doesn't work.
I've also tried version 1.17.0-beta3 with the same result as v1.16.1.
(By the way, Linux Mint 19's codename is Tara.)

Here is the full log in trace log level, version 1.15.1:

Starting OmniSharp server at 2018-10-3 10:37:27
    Target: /home/$USER/Sources/Unity/First game project/First game project.sln

OmniSharp server started with Mono 5.14.0
    Path: /home/$USER/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1/omnisharp/OmniSharp.exe
    PID: 901

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <c01404811b784b23ba2b531f165478f7>:0 
  at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x0035b] in <e56ebbc3ed87488b8e26736bbadaa5d3>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <c01404811b784b23ba2b531f165478f7>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_1.<Main>b__0 () [0x00028] in <93ea459c1f92407098a355199aa33d94>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <c01404811b784b23ba2b531f165478f7>:0 

And here it is with version 1.17.0-beta3:

Starting OmniSharp server at 2018-10-3 10:41:12
    Target: /home/$USER/Sources/Unity/First game project/First game project.sln

OmniSharp server started with Mono 5.14.0.
    Path: /home/$USER/.vscode/extensions/ms-vscode.csharp-1.17.0-beta3/.omnisharp/1.32.5/omnisharp/OmniSharp.exe
    PID: 1130

System.TypeLoadException: Could not load type of field 'McMaster.Extensions.CommandLineUtils.CommandLineApplication:_validationErrorHandler' (36) due to: Could not load file or assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  at OmniSharp.Stdio.StdioCommandLineApplication..ctor () [0x00000] in <e2653a02ab1f423abb805f2353ec9507>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00006] in <9671bf457f144c419fb0cdee3ca10088>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <48aa3fb56cea4bd5ab9bfdf1170dd033>:0 
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

I experienced the same issue on Ubuntu 16.04. I had monoruntime package installed. For me, setting omnisharp.useGlobalMono to Never solved the issue.

Ran into this on CentOS 7, but fixed it by installing msbuild and libunwind with sudo yum install msbuild libunwind.

OK, so apparently just installing msbuild did the trick.
Thanks gzmp!

For me installing the mono-complete package following this fixed the error for me.

Thanks a lot! Now it truly works (I maybe should have mentioned that even though this first specific error was corrected, I required the .NET 3 framework or something like that, so I just abandoned as I couldn't find any Linux .NET package...).
Although I just needed to install the mono-devel package as told in that link you sent.

Was this page helpful?
0 / 5 - 0 ratings