我在Visual Studio 2015中遇到错误我使用的是Windows 8.1和visual studio 2013,所有使用asp.net MVC 5的项目都正常运行并且没有任何错误。
自从我安装了Windows 10和visual studio 2015以来,我的整个ASP.NET MVC 5项目都运行不正常。
我在visual studio 2015中创建了新的默认模板来检查它们。我在这些新项目上也遇到了同样的错误。
我得到错误:
CS0234命名空间“Microsoft.AspNet”中不存在类型或命名空间名称“Mvc”(您是否缺少程序集引用?)
和
当前上下文中不存在名称“布局”。
**我已经尝试过的事情:**
我在%AppData%\ Microsoft \ VisualStudio \ 14.0 \ ActivityLog.xml中收到此错误:
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Item has already been added. Key in dictionary: 'RazorSupportedRuntimeVersion' Key being added: 'RazorSupportedRuntimeVersion'
 at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
 at System.Collections.Hashtable.Add(Object key, Object value)
 at System.Collections.Specialized.HybridDictionary.Add(Object key, Object value)
 at Microsoft.VisualStudio.Utilities.PropertyCollection.AddProperty(Object key, Object property)
 at Microsoft.VisualStudio.Html.Package.Razor.RazorVersionDetector.Microsoft.Html.Editor.ContainedLanguage.Razor.Def.IRazorVersionDetector.GetVersion(ITextBuffer textBuffer)
 at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorUtility.TryGetRazorVersion(ITextBuffer textBuffer, Version& razorVersion)
 at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorErrorTagger..ctor(ITextBuffer textBuffer)

我运行C:\“Program Files(x86)”\“Microsoft Visual Studio 14.0”\ Common7 \ IDE \ devenv.exe / resetuserdata并修复了它。
我按照这些步骤完全重新安装Visual Studio 2015,解决了这个问题。修复没有工作
我在Visual Studio 2015中遇到了同样的问题,每次打开我的ASP.NET 5.0项目时都会遇到错误,但是当我再次重新打开应用程序时,错误就会消失。
顺便说一下,问题似乎是关于正确的版本控制,例如,如果您使用的是ASP.NET 5.0的Beta 7.0,也许某些软件包仍然使用以前的版本,如Beta 5.0,...
我遇到了这个错误,并且能够通过编辑web.config的runtime/assemblyBinding
部分来解决它,如下所示:
<!-- Original //-->
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<!-- Changed to... //-->
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
这可能位于主web.config
文件和/或Views目录中的文件中
希望这可以帮助!