Search code examples
c#visual-studio-codeomnisharp

VSCode Omnisharp is not working and code action is not available


Hello all: I am having issue getting omnisharp to work on vs code. it seems to load without any error messages but as soon as I click on an underlined code error appears as below:

{
  "Type": "request",
  "Seq": 117,
  "Command": "/v2/getcodeactions",
  "Arguments": {
    "FileName": "c:\\Users\\timch\\Desktop\\workFolder\\AngularBlog\\Startup.cs",
    "Line": 44,
    "Column": 30
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (5469.1211ms) ************ 
{
  "Request_seq": 117,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.\\r\\nCould not load file or assembly 'Microsoft.CodeAnalysis.VisualBasic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. File specified could not be found \\r\\nCould not load file or assembly 'Microsoft.CodeAnalysis.VisualBasic, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. File specified could not be found\\r\\n   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c.<LoadFrom>b__6_0(AnalyzerFileReference analyzerFileReference) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\CachingCodeFixProviderForProjects.cs:

There are a lot more below but they are pretty much repeatedly complaining about the same thing. I have searched for this issue and tried to reinstall all nuget packages and vscode itself but to no solution. May I please get some help on this?

Thank you very much.

  • removed .vscode and .vs and tried dotnet restore
  • removed all nuget packages and reinstalled them
  • add "omnisharp.path" = "latest" and "omnisharp.useModernNet": true,
  • reinstalled vscode

Solution

  • Turns out it was one of the package that was added that caused the issue when I was using the dotnet upgrade tool. Removing the package reference in the csproj file and running dotnet restore resolved my issue.