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.

C# Extension fails only for netcoreapp3.0 GA

See original GitHub issue

Issue Description

C# Extensions complains “The type or namespace name ‘System’ could not be found …” (likewise System.String, System.Object, System.Void, etc.)

This happens only when Target Framework = netcoreapp3.0. No problems for netcoreapp2.0, netcoreapp2.1, nor netcoreapp2.2. Code builds and runs fine at command prompt.

Steps to Reproduce

  1. Installed software
  • VS Code latest (1.38.1)
  • C# Extensions latest (1.21.3)
  • . . . with OmniSharp latest (1.34.3)
  • .NET Core 3.0 SDK (3.0.100)
  • Restart workstation after installs (just in case)
  1. Actions in Command Prompt
  • Create folder = OmniDemo
  • Create new console app in that folder: dotnet new console
  • dotnet build => builds successfully
  • dotnet run => runs successfully
  • Inspect .csproj file => App uses TargetFramework = netcoreapp3.0.
  1. Open VS Code in this folder
  • Warning = No assets … => Accept to add assets
  • Warning = Unresolved dependencies => Accept to restore
  • Warning (repeated) = Unresolved dependencies => Accept to restore

Expected Behavior

C# Extensions displays c# code without any errors independent of whether TargetFramework = netcoreapp3.0, 2.2, 2.1, or 2.0.

Actual Behavior

C# Extensions accepts code for 2.0, 2.1, and 2.2.

For netcoreapp3.0 completely different behavior => C# Extensions complains of syntax errors (no type or namespace name) for System, System.String, System.Object, System.Void, etc.

Logs

OmniSharp log

Starting OmniSharp server at 9/23/2019, 11:34:25 PM Target: c:\DEV\OmniDemo

OmniSharp server started. Path: C:\Users\mickr.vscode\extensions\ms-vscode.csharp-1.21.3.omnisharp\1.34.3\OmniSharp.exe PID: 13104

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: Visual Studio Community 2017 15.9.28307.770 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
        2: StandAlone 16.0 - "c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin"
    MSBUILD_EXE_PATH environment variable set to 'c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin\MSBuild.exe'
    Registered MSBuild instance: StandAlone 16.0 - "c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin"
        CscToolExe = csc.exe
        CscToolPath = c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin\Roslyn
        MSBuildExtensionsPath = c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild
        MSBuildToolsPath = c:\Users\mickr\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin
    Detecting Cake files in 'c:\DEV\OmniDemo'.
    Could not find any Cake files
    No solution files found in 'c:\DEV\OmniDemo'
    Queue project update for 'c:\DEV\OmniDemo\OmniDemo.csproj'
    Detecting CSX files in 'c:\DEV\OmniDemo'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Loading project: c:\DEV\OmniDemo\OmniDemo.csproj
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\DEV\OmniDemo' on host 3140.
    Successfully loaded project file 'c:\DEV\OmniDemo\OmniDemo.csproj'.
    Adding project 'c:\DEV\OmniDemo\OmniDemo.csproj'
    Update project: OmniDemo

[warn]: OmniSharp.MSBuild.PackageDependencyChecker OmniDemo: Did not find ‘Microsoft.NETCore.App’ in lock file. info: OmniSharp.MSBuild.ProjectManager Queue project update for ‘c:\DEV\OmniDemo\OmniDemo.csproj’ info: OmniSharp.MSBuild.ProjectManager Loading project: c:\DEV\OmniDemo\OmniDemo.csproj info: OmniSharp.MSBuild.ProjectManager Successfully loaded project file ‘c:\DEV\OmniDemo\OmniDemo.csproj’. info: OmniSharp.MSBuild.ProjectManager Update project: OmniDemo [warn]: OmniSharp.MSBuild.PackageDependencyChecker OmniDemo: Did not find ‘Microsoft.NETCore.App’ in lock file.

C# log

C# log is EMPTY

Environment information

VSCode version: 1.38.1 C# Extension: 1.21.3

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26

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

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

.NET Core SDKs installed: 2.1.403 [C:\Program Files\dotnet\sdk] 2.1.500 [C:\Program Files\dotnet\sdk] 2.1.508 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.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.3
mssql ms-mssql 1.6.0
remote-wsl ms-vscode-remote 0.39.5
team ms-vsts 1.149.2
vscode-eslint dbaeumer 1.9.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:36 (10 by maintainers)

github_iconTop GitHub Comments

11reactions
DanielKOceancommented, Sep 24, 2019

Guys, I’ve got the solution (for those, who don’t want to install VS2019).

  1. Go to Microsoft VS downloads.
  2. Download “Build Tools for Visual Studio 2019”, then install it.
  3. Go to modify -> Individual components, ccheck “.NET Core 3.0 SDK”. Install.
  4. Start your VS Code and have fun.

After it I get this output:

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio Professional 2017 15.9.28307.858 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
            2: Visual Studio Build Tools 2019 16.3.29318.209 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
            3: StandAlone 16.0 - "C:\Users\*********\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.3\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2019 16.3.29318.209 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"

So correct version of MSBuild is now used by OmniSharp. But don’t forget about step 3, solution need .Net Core 3.0 SDK for VisualStudio.

9reactions
filipwcommented, Sep 24, 2019

If you are on Linux or MacOS you may want to try install Mono 6.0.0 https://www.mono-project.com/download/stable/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using extension methods in C# - Stack Overflow
I just ran into this problem myself. In my case, it was because I converted a VS 2005/.Net 2.0 project to a VS...
Read more >
Develop Azure Functions using .NET Core 3.1
0 logging component we've written, it complains with the following. Error System.IO.FileNotFoundException: Could not load file or assembly ' ...
Read more >
Could not load file or assembly Microsoft.IntelliTrace.Core
[regression] [worked-in:16.3.0 Preview 4.0] I am getting the following exception when running a unit test in a .NET Core 3.0 API project: Message:...
Read more >
NET Core 3 for Windows Desktop - Microsoft Developer Blogs
Responsive low-latency UI; Applications that need to run offline/disconnected; Applications with dependencies on custom device drivers. This is ...
Read more >
How to fix "The type or namespace name 'Services' does not ...
In my case, the error happened after updates to Visual Studio. ... [projectname]\obj\Debug\netcoreapp3.0\RazorDeclaration\Shared\MainLayout.
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