vscode-csharp: Missing predefined types and namespaces

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.200)

Product Information:
 Version:            2.1.200
 Commit SHA-1 hash:  2edba8d7f1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.200\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

VS Code version: 1.23.1 C# Extension version: 1.15.1 (OmniSharp 1.30.0)

Steps to reproduce

After opening an existing project, all source files in the project are flagged with these errors (types and namespaces can be treated as wildcards as all predefined types, top-level namespaces, and types imported from referenced packages or the framework itself are error-flagged):

  • Predefined type ‘System.Object’ is not defined or imported
  • The type of namespace name ‘System’ could not be found in the global namespace (are you missing an assembly reference?)

Per issue #1855 I do have a valid and up to date install of Visual Studio 2017 Community as selected by OmniSharp:

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\Chris\.vscode\extensions\ms-vscode.csharp-1.15.1\.omnisharp\1.30.0\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2017 15.7.27703.2000 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"

I’ve confirmed that the path to MSBuild for VS 2017 exists and contains a functional install of MSBuild.

Expected behavior

Predefined types, and both namespaces and types from referenced packages would not be marked as errors.

Actual behavior

Red squigglies. Red squigglies everywhere. And every source file in the project shown in red in the workspace explorer pane.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

The fix for this has been pushed into OmniSharp. You should be able to get the fix by setting the "omnisharp.path" option in VS Code to "latest". That will cause C# for VS Code to download the latest build OmniSharp at start up.

Again, thanks very much for the repro. I have a fix prototyped.