2015-10-04 38 views
9

我在Visual Studio 2015中收到錯誤 我正在使用Windows 8.1和Visual Studio 2013,並且所有使用asp.net MVC 5的項目都在工作並沒有任何錯誤地發展良好。Visual Studio 2015新MVC項目 - mvc不存在於Microsoft.Aspnet

由於我安裝了Windows 10和Visual Studio 2015,我的整個ASP.NET MVC 5項目無法正常工作。

我在visual studio 2015中創建了新的默認模板來檢查它們。我也對這些新項目也有同樣的錯誤。

我得到的錯誤爲:(?是否缺少程序集引用)

CS0234類型或命名空間名稱 '的mvc' 不會在 命名空間 'Microsoft.AspNet' 存在

名稱「Layout」在當前上下文中不存在。

**事情我已經嘗試:**

  1. 修復VS 2015
  2. 卸載並安裝了的NuGet安裝,包裝Microsoft.AspNet.Mvc
  3. 複製本地=真
  4. 已引用System.web.MVC。
  5. 的web.config的版本的所有地方5.2.3.0
+1

重新打開項目可解決您的問題。 –

+0

我已經嘗試重新打開和卸載和加載項目,但仍然即時獲得該錯誤 –

回答

3

兩者我跟着要想徹底重新安裝的Visual Studio 2015年這解決了這個問題這些步驟。維修沒有工作

  1. 運行命令

    C:\ Program Files文件(x86)的\微軟的Visual Studio 14.0 \ Common7 \ IDE \ devenv的。EXE/resetuserdata

  2. 下載web安裝程序安裝文件,並在下載目錄中運行以下命令

    vs_community.exe /卸載/力

  3. 卸載後,我確信沒有與VS相關的文件軟件安裝並重新啓動PC

  4. 使用Web安裝程序安裝了新的Visual Studio。
  5. 再次運行該命令。

    C:\ Program Files文件(x86)的\微軟的Visual Studio 14.0 \ Common7 \ IDE \ devenv.exe的/ resetuserdata

  6. 更新是可用在Visual Studio中,安裝了他們 - 而重新啓動的Visual Studio

  7. 現在打開任何asp.net mvc解決方案,雖然在開始時需要花費時間,但在此之後它可以正常工作。

1

我與Visual Studio 2015年同樣的問題,每次我打開我的ASP.NET 5.0項目時,我得到這個錯誤,但是當我重新再次打開應用程序,錯誤消失。

通過這個問題似乎有關正確的版本,例如,如果您使用的是測試版7.0 ASP.NET 5.0中,也許有些包仍然使用以前的版本一樣Beta版5.0,順便......

+0

我已經嘗試重新打開和卸載和加載項目,但仍然即時獲取該錯誤。在我的應用程序中可能會出現這樣的情況:軟件包使用其他版本,但它發生在我的默認新visual Studio 2015項目中 –

4

我得到這個誤差%APPDATA%\微軟\ 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. ---&gt; System.ArgumentException: Item has already been added. Key in dictionary: &apos;RazorSupportedRuntimeVersion&apos; Key being added: &apos;RazorSupportedRuntimeVersion&apos;&#x000D;&#x000A; at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)&#x000D;&#x000A; at System.Collections.Hashtable.Add(Object key, Object value)&#x000D;&#x000A; at System.Collections.Specialized.HybridDictionary.Add(Object key, Object value)&#x000D;&#x000A; at Microsoft.VisualStudio.Utilities.PropertyCollection.AddProperty(Object key, Object property)&#x000D;&#x000A; at Microsoft.VisualStudio.Html.Package.Razor.RazorVersionDetector.Microsoft.Html.Editor.ContainedLanguage.Razor.Def.IRazorVersionDetector.GetVersion(ITextBuffer textBuffer)&#x000D;&#x000A; at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorUtility.TryGetRazorVersion(ITextBuffer textBuffer, Version&amp; razorVersion)&#x000D;&#x000A; at Microsoft.Html.Editor.ContainedLanguage.Razor.RazorErrorTagger..ctor(ITextBuffer textBuffer)&#x000D;&#x000A; 

我跑了C:\ 「程序文件(x86)」 \ 「微軟的Visual Studio 14.0」 \ Common7 \ IDE \ devenv.exe的/ resetuserdata並且它已修復。

Exception when opening a cshtml file

+0

我也試過這個也沒有工作。 –

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文件和/或視圖目錄中的一個

希望這有助於!

+0

碰到同樣的問題。迄今爲止,建議的解決方案都沒有奏效。任何其他建議 – BrilBroeder

+0

@BrilBroeder你有沒有嘗試重新安裝Visual Studio,我發佈的解決方案? –

+0

@ShanKhan重新安裝了它。謝謝。但是在Win10上VS2015仍然非常慢。但是,這是我有一些時間後,我必須考慮的另一個問題:-) – BrilBroeder

相關問題