[英]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.