ahmed.ramadan
ahmed.ramadan

Reputation: 47

missing "System" reference on ubuntu and .net core 3.0

I'm trying to develop a simple web app using .Net Core 3.0 on an Ubuntu machine. I setup the .Net Core SDK and the runtime from this link. I setup VS Code and then I create a project using the following commands dotnet new webapp -o RazorPagesMovie code -r RazorPagesMovie

I built the project and it is working. But in VS Code, it shows the following error:

The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) 

screenshot of vs code

Upvotes: 3

Views: 1503

Answers (3)

Stephan Erickson
Stephan Erickson

Reputation: 1

On Mac I tried removing old dot net runtimes and sdks, using the preview version of omnisharp and verifying mono version above 6.0.0 I also deleted project bin and obj dirs, recompiled, deleted nuget cache dirs and restored.

Then I ran across this in related post: ACK! Upgrading to Mono 6.4 solves problem under Linux! (Under Mono 6.0 problem occurs as I have had this version before) Not 6.0 necessarily....

Upvotes: 0

kahveci
kahveci

Reputation: 1457

Regarding your problem, there are multiple open issues on omnisharp-vscode (e.g. 3289, 3290) GitHub repository. A few workarounds are available as follows:

  • For Windows: install Visual Studio 2019 Community Edition, or MsBuild Tools 2019
  • For Linux/MacOS: install Mono 6.0.0 or newer

Or uninstall the previous versions of .NET Core. If you don't like these workarounds, the best solution to fix the issue is that installing the new (beta) OmniSharp build for the time being.

You can install this build by adding the following line into your VS Code settings.json:

"omnisharp.path": "1.34.4-beta.7"  

Once you save the settings, the new build of omnisharp-vscode with fix will be installed. After the installation, restart IDE if required. I can confirm that the fix works for Windows.

Upvotes: 5

onemorecupofcoffee
onemorecupofcoffee

Reputation: 2447

I often get a similar message on .net core 2.x and I find that you have to add the reference to netstandard into the project file to fix as below:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    ..
  </PropertyGroup>
  <ItemGroup>
    ..
  </ItemGroup>

  <ItemGroup> <Reference Include="netstandard" /> </ItemGroup>
</Project>

Upvotes: 0

Related Questions