ProjectReference results in "type or namespace name 'System' could not be found" when Multi-Trageting
See original GitHub issueEnvironment 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:
- Created 6 years ago
- Comments:26 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
No, there’s no way to do that. OmniSharp really only calls the
Compile
andCoreCompile
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.