Omnisharp-vscode: 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.

Created on 30 Jan 2020  Â·  6Comments  Â·  Source: OmniSharp/omnisharp-vscode

Issue Description

An error message when OmniSharp initializes on a newly created webapi project.

Steps to Reproduce

Create a webapi project and install OmniSharp

Expected Behavior

To have no error.

Actual Behavior

Error.

Logs

OmniSharp log

Starting OmniSharp server at 1/30/2020, 11:51:34 AM
    Target: /home/gabriel/Workspace/careplus-email-api

OmniSharp server started with Mono 5.18.0.
    Path: /home/gabriel/.vscode/extensions/ms-vscode.csharp-1.21.9/.omnisharp/1.34.9/omnisharp/OmniSharp.exe
    PID: 24986

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 <27dcabbd1f5d4edeaffe820a1236c676>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00006] in <2d02054c9f224f8aa95299738e820ffb>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <1ed0cdfb5a5d42889b4f5df087ff7bd6>:0 
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

C# log

I don't know how to do it

Environment information

VSCode version: 1.41.1
C# Extension: 1.21.9
OS: Ubuntu 19.10 64 bits

Mono Information
OmniSharp using global mono :5.18.0

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.1.101
Commit: b377529961

Runtime Environment:
OS Name: ubuntu
OS Version: 19.10
OS Platform: Linux
RID: ubuntu.19.10-x64
Base Path: /usr/share/dotnet/sdk/3.1.101/

Host (useful for support):
Version: 3.1.1
Commit: a1388f194c

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

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.1 [/usr/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|
|---|---|---|
|csharp|ms-vscode|1.21.9|
|dart-code|Dart-Code|3.7.1|
|flutter|Dart-Code|3.7.1|
|vscode-great-icons|emmanuelbeziat|2.1.47|;

Needs Investigation Triaged

Most helpful comment

@konradmb Yes! sudo apt install mono-complete fixed it for me. Pop!_os 20.04 mono 6.8.0.105

All 6 comments

OmniSharp server started with Mono 5.18.0.

Hi @mfgabriel92, OmniSharp requires Mono 6.6.0 or higher. Can you update to the stable release? https://www.mono-project.com/download/stable/#download-mac

Hi @JoeRobich. It solved it. Thanks.

Hello,

It happened again, and this time I have version 6.8.0.105.

Have the same problem, maybe the reason is I've just updated to Ubuntu 20.04 beta, and yeah, it is beta, but will be stable in 10 days. My output:

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 <0f4d64c713a44cb7b327f623e35918a5>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00006] in <053e8164eb434b63be8247033b33692f>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <cc784888e5004669a7cdfce6a3d2dba5>:0 
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

@jpietrzyk Basically, OmniSharp can't load required assemblies. You can try either installing mono-complete package or setting "omnisharp.useGlobalMono": "never" in VSCode settings.

Installing mono-complete is a better way, because you'll get more libraries, newer version etc.

I wonder why loading internal mono isn't the default, especially when OmniSharps ships it inside the extension, and Ubuntu has a stripped down version of mono by default.
But it could lead to even more problems…

@konradmb Yes! sudo apt install mono-complete fixed it for me. Pop!_os 20.04 mono 6.8.0.105

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregg-miskelly picture gregg-miskelly  Â·  3Comments

jrmcdona picture jrmcdona  Â·  3Comments

nguillermin picture nguillermin  Â·  3Comments

Alumniminium picture Alumniminium  Â·  3Comments

hamhub7 picture hamhub7  Â·  3Comments