类型或命名空间名称'系统'找不到 [英] The type or namespace name 'System' could not be found

查看:958
本文介绍了类型或命名空间名称'系统'找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的所有视图(* .cshtml)在Visual Studio中打开我的项目时,2015年专业。

I have the following errors (and more) in all my views (*.cshtml) when opening my project in Visual Studio 2015 Professional.

错误CS0246类型或命名空间名称'系统'找不到(是否缺少using指令或程序集引用?)
  严重code说明项目文件中的行

Error CS0246 The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) Severity Code Description Project File Line

错误CS0518 predefined类型'System.Object的'未定义或导入
  严重code说明项目文件中的行

Error CS0518 Predefined type 'System.Object' is not defined or imported Severity Code Description Project File Line

错误CS0518 predefined类型'System.String'未定义或导入

Error CS0518 Predefined type 'System.String' is not defined or imported

我得到了这些引用:

<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Sitecore.Kernel, Version=7.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\Sitecore.Kernel.dll</HintPath>
</Reference>
<Reference Include="Sitecore.Mvc">
  <HintPath>N:\XXX\Sitecore.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Providers">
  <HintPath>N:\XXX\System.Web.Providers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>N:\XXX\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />

我找到了一些解决方案,说一个mscorlib中并没有提及。但是,当我试图添加它,它sayd它已经存在(尽管我没有看到它的的csproj文件)。

I found some solutions saying that a mscorlib wasn't referenced.. but when I tried to add it it sayd that it's already there (even though I don't see it on the csproj file).

System.dll中引用:

System.dll reference:

在这里输入的形象描述

在这里输入的形象描述

解决方案:

管理的问题。我不得不构建路径设置为C:\\ BIN而不是\\ bin中。我相信这发生,因为我没有在项目的根web.config中的任何,所以VS没有确定我的项目作为一个Web项目。

Managed the issue.. I had the build path set to a "c:...\bin" instead of "\bin". I believe this happened because I don't have any web.config in the root of the project, so VS didn't identify my project as a web project.

推荐答案

我试图重新创建您的问题,并与类似的错误想出了当溶液在Visual Studio 2013创建,然后试图建立它在VS 2015我能得到一个成功的构建一旦我重新安装的NuGet包管理器(和闭环>重新VS 2015)。

I attempted to re-create your issue and came up with a similar error when the solution was created in visual studio 2013 and then tried building it in in vs 2015. I was able to get a successful build once i reinstalled NuGet Package Manager (and closed->reopened VS 2015).

参考/信用。有关于通过与2015年VS早期版本的NPM(即我只是沿着我所尝试和摸索出合格)建设若干问题的SO问题。经常性的分辨率通常是更新/重新安装电源外壳NPM或更改执行策略。我倾向于喜欢更新+重启的办法,以避免与Windows中的黑盒子修修补补。一个来源: http://stackoverflow.com/a/32251092/1158842 也可能有MSBuild的集成解决方案的问题在这种情况下,溶液中的迁移距离的NuGet资源远可以做的伎俩。来自: http://stackoverflow.com/a/31811461/1158842

References / Credit. There are several SO questions relating to build issues via with earlier version of NPM for VS 2015 (ie i'm just passing along what i've tried and worked out). Recurring resolution is usually update / reinstall NPM or change execution policy in power shell. I tend to like the update + restart approach to avoid tinkering with the black boxes in windows. one source: http://stackoverflow.com/a/32251092/1158842 There may also be an issue of MSBuild Integrated solutions, in which case migrating away from the nuget resources in the solution could do the trick. from: http://stackoverflow.com/a/31811461/1158842

这篇关于类型或命名空间名称'系统'找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆