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.

ProjectReference results in "type or namespace name 'System' could not be found" when Multi-Trageting

See original GitHub issue

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.4)

Product Information:
 Version:            2.1.4
 Commit SHA-1 hash:  5e8add2190

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.4/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.5
  Build    : 17373eb129b3b05aa18ece963f8795d65ef8ea54

VS Code version: 1.20.1

C# Extension version: 1.14.0

Steps to reproduce

1- Create a mstest project 2- Open the folder in VS Code; verify there are no errors; Close the Folder 3- use DOTNET ADD to add a ProjectReference outside of root directory to the mstest project. The Reference Project must have use TargetFrameworks (multi-Target) not TargetFramework. 4- Open the folder in VS Code;

Expected behavior

No Problems/Error given that “dotnet build” works.

Actual behavior

Problem Panel displays lots of errors

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
CodeSwimBikeRunnercommented, Jan 8, 2019

Sorry how do we get this version in vscode? I’m on windows and see 1.17.1 for the c# extension. It appears to have omnisharp 1.31+, but it still can’t pick up using System and tons of errors.

Here is my OmniSharp output

Starting OmniSharp server at 1/8/2019, 2:58:03 PM
    Target: c:\Users\user\Source\project_root\project_name.sln

OmniSharp server started.
    Path: C:\Users\user\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe
    PID: 11172

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Professional 2017 15.6.27428.2002 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
            2: StandAlone 15.0 - "C:\Users\user\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Professional 2017 15.6.27428.2002 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\user\Source\project_root'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in 'c:\Users\user\Source\project_root\project_name.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\user\Source\project_root\project_name\project_name.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\user\Source\project_root'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\user\Source\project_root\project_name\project_name.csproj
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Users\user\Source\project_root' on host 21164.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Users\user\Source\project_root\project_name\project_name.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Users\user\Source\project_root\project_name\project_name.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: project_name
2reactions
DustinCampbellcommented, May 29, 2018

No, there’s no way to do that. OmniSharp really only calls the Compile and CoreCompile targets, which depend on a lot of other targets. I suspect that disabling some would mean that things just don’t work.

I’ve made a few fixes to OmniSharp in this area recently. In particular, we identified a problem where it would fail to handle multi-targeted projects that were referenced outside of the current solution or folder that OmniSharp was launched with. Could you try using that version and see if it helps with this particular issue? You can use it by setting "omnisharp.path" to "latest" in the VS Code settings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The type or namespace name 'System' could not be found
I have the following errors (and more) in all my views (*.cshtml) when opening my project in Visual Studio 2015 Professional. Error CS0246...
Read more >
The type or namespace name 'System' could not be found
The type or namespace name 'System' could not be found. When I try to create a new Xamarin Forms app, nothing works. No...
Read more >
Type or namespace could not be found
Hi, I'm getting a type or namespace could not be found in VS 2019. ... Removing the project reference and adding it back...
Read more >
Working With Multi-Target .NET Solutions - Forty Years of Code
Configuration namespace results in a runtime error. ... You can see the namespaces and class names are the same, but Visual Studio doesn't ......
Read more >
Type or namespace not found: how to fix Error CS0246 in . ...
Error CS0246 : The type or namespace name 'XX' could not be found (are you missing a using directive or an assembly reference?)....
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