question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing predefined types and namespaces

See original GitHub issue

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.

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
DustinCampbellcommented, May 21, 2018

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.

1reaction
DustinCampbellcommented, May 18, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve Missing Namespaces in Code Samples
In this case, Visual Studio can help us resolve the missing namespace. ... Configuration, which is not referenced by default in windows forms...
Read more >
Type or namespace name does not exist - Stack Overflow
I found that this is caused by me having the same namespace name as class name ( MyWorld.MyWorld = Namespace. ... That project...
Read more >
Type.Missing Field (System) - Microsoft Learn
Represents a missing value in the Type information. ... Namespace: System ... the use of the Missing field to invoke a method with...
Read more >
Import missing namespaces - ReSharper - JetBrains
The missing namespaces are imported according to your namespace import preferences (for example, import directives are inserted or type names ...
Read more >
XML Schema: Understanding Namespaces - Oracle
It would be painful to repeatedly qualify an element or attribute you wish to use from a namespace. In such cases, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found