简体   繁体   English

Visual Studio 2017找不到命名空间系统

[英]Visual Studio 2017 can't find namespace System

In one of my projects, Visual Studio says it can't find namespace System and similar Microsoft standard assemblies. 在我的一个项目中,Visual Studio说它找不到名称空间System和类似的Microsoft标准程序集。 It also can't load other projects in the other solution that it depends on. 它也无法在其依赖的其他解决方案中加载其他项目。

To clarify, it DOES build, but pretty much every line in that project which references another project has a squiggly red "error" underlining. 要澄清的是,它确实可以构建,但是该项目中引用另一个项目的每一行几乎都有红色的“错误”下划线。

When loading this solution, or when trying to add a dependency to this project (by right clicking Dependencies and selecting 'Add Reference...', I get this message: 加载此解决方案时,或尝试向该项目添加依赖项时(通过右键单击Dependencies并选择“ Add Reference ...”,我会收到以下消息:

An element with the same key but a different value already exists. 具有相同键但值不同的元素已存在。 Key: Microsoft.CodeAnalysis.CSharp 密钥:Microsoft.CodeAnalysis.CSharp

The top of the csproj file is: csproj文件的顶部是:

<Project Sdk="Microsoft.NET.Sdk.Web"> 

 <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
    <NoWarn>$(NoWarn)</NoWarn>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
  </PropertyGroup>

事实证明,在.csproj中两次引用了Microsoft.CodeAnalysis.CSharp程序集,并删除了重复项,从而解决了该问题。

I had this same problem few days back. 几天前我也遇到了同样的问题。 Actually this problem occurs when you upgrade to Visual Studio 2017 and you try to run projects created on older version of VS. 实际上,当您升级到Visual Studio 2017并尝试运行在旧版VS上创建的项目时,就会发生此问题。

1) First you have make the Target Framework equal for every module in the project. 1)首先,使目标框架与项目中的每个模块均等。

2) Then you might have to upgrade Nuget packages with latest version for all modules. 2)然后,您可能必须为所有模块升级具有最新版本的Nuget软件包。

3) Add missing references. 3)添加缺少的参考。

4) run VS as administrator, clean and build it again. 4)以管理员身份运行VS,清理并重新构建它。

You will get the solution. 您将获得解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到System.Deployment文件Visual Studio 2017 OpenCV - Can't find System.Deployment file Visual Studio 2017 OpenCV 我在 Visual Studio 2019 中找不到 System.Media 命名空间 - I can't find the System.Media namespace in Visual Studio 2019 Visual Studio 2017 找不到解决方案中存在的文件夹 - Visual Studio 2017 can't find folder that exists in the solution 在 Visual Studio 2017 中找不到类图 - Can't find the Class Diagram in Visual Studio 2017 为什么我在Visual Studio中的对象浏览器中找不到System.Windows.Controls命名空间? - Why don't I find the System.Windows.Controls namespace in my object browser in Visual Studio? 我在Visual Studio 2017上找不到跨平台应用程序Xamarin - I can't find cross platform app Xamarin on visual studio 2017 在Visual Studio引用(对象浏览器)的“系统”名称空间中查找控制台类 - Find Console class in System namespace in Visual Studio references (Object browser) 在 Visual Studio 2017 中找不到“类型或命名空间” - 'the type or namespace could not be found' in Visual Studio 2017 Visual Studio 2017中CommandLine名称空间中的问题 - Facing issues in CommandLine namespace in Visual studio 2017 Visual Studio Community 2017 中缺少命名空间 Tcp - Missing Namespace Tcp in Visual Studio Community 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM