首页 > 解决方案 > 在 Vscode 中调试 C# 代码时出现 System.TypeLoadException

问题描述

当我安装 C# 扩展时,一切正常。但是后来我安装了 Mono(并出于某种原因将其卸载)并且扩展现在不起作用

我再次尝试卸载并安装 dotnet3,但这没有任何意义。

Starting OmniSharp server at 10/7/2019, 11:23:01 AM
    Target: /home/newusername77177/ProgrammingFolder/C#/Study

OmniSharp server started with Mono 6.4.0.
    Path: /home/newusername77177/.vscode/extensions/ms-vscode.csharp-1.21.4/.omnisharp/1.34.4/omnisharp/OmniSharp.exe
    PID: 9152

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

标签: c#debuggingvisual-studio-codemono

解决方案


尝试在 vscode 中设置 Omnisharp: Use Global Mono to never 而不是 auto。为我工作。


推荐阅读