missing “System” reference on ubuntu and .net core 3.0

假如想象 提交于 2020-01-05 08:34:27

问题


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


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/58106158/missing-system-reference-on-ubuntu-and-net-core-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!