在Visual Studio 2015 Professional中打開項目時,我在所有視圖(* .cshtml)中出現以下錯誤(以及更多)。無法找到類型或名稱空間名稱'System'
錯誤CS0246類型或命名空間名稱「系統」找不到(是否缺少using指令或程序集引用?) 嚴重性代碼說明項目文件行
錯誤CS0518預定義類型「系統.Object」沒有定義或導入 嚴重性代碼說明項目文件行
錯誤CS0518預定義類型‘System.String’沒有定義或導入
我得到了這些引用:
<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文件上看不到它)。
System.dll中參考:
SOLUTION:
管理的問題。我不得不設置爲「C構建路徑:... \ bin「而不是」\ bin「。我相信這是因爲我沒有任何web.config項目的根目錄,所以VS沒有將我的項目標識爲Web項目。
沒有工作.... –
沒有什麼奇怪的。你的觀點中有沒有使用條款?如果沒有,你可能不必,我敢打賭,你可以通過Views web.config隱式添加它...看到這個問題http://stackoverflow.com/questions/12547641/how-do-i-avoid-adding-using -in-MY-CSHTML標籤 –
的問題不僅與使用條款..這也是當我嘗試做@Html,請查看更新的問題 –