Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 New MVC Project - the mvc does not exist in Microsoft.Aspnet

I'm getting an error in Visual Studio 2015 I was using windows 8.1 and visual studio 2013 and all projects with asp.net MVC 5 were working and developing fine without any error.

Since I installed windows 10 and visual studio 2015 my whole ASP.NET MVC 5 project doesn't work well.

I created new default template in visual studio 2015 to check them. I got the same error on those new project also.

I get errors as :

CS0234 The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNet' (are you missing an assembly reference?)

And

The name "Layout" doesn't exist in current context.

**Things I have already Tried: **

  1. Repaired VS 2015.
  2. Uninstalled and installed Install-Package Microsoft.AspNet.Mvc from Nuget
  3. Copy Local = True
  4. System.web.MVC already referenced.
  5. The version of web.config all places 5.2.3.0
like image 255
Shan Khan Avatar asked Oct 04 '15 19:10

Shan Khan


3 Answers

I was getting this error in %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. ---&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; 

I ran C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\Common7\IDE\devenv.exe /resetuserdata and it was fixed.

Taken from Exception when opening a cshtml file

like image 79
Carling Avatar answered Nov 06 '22 23:11

Carling


I followed these steps in order to completely re-install Visual Studio 2015 which solved the problem. Repair didnt work

  1. run the command

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /resetuserdata

  2. Downloaded the web installer setup file and run the following command in the downloaded directory

    vs_community.exe /uninstall /force

  3. After Uninstalling i made sure no file software related to VS is installed and restarted PC

  4. Installed new Visual Studio using Web Installer.
  5. Run the command again.

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe /resetuserdata

  6. Updates were available inside Visual Studio , installed them - Restarted Visual Studio

  7. Now open any asp.net mvc solution it takes time though in start but after that it works.

like image 26
Shan Khan Avatar answered Nov 07 '22 01:11

Shan Khan


I have the same problem with Visual Studio 2015, every time I open my ASP.NET 5.0 project I get that error, But when I re-open the application again, the errors go away.

By the way the problem seems about correct versioning for example if you are using the Beta 7.0 of ASP.NET 5.0, maybe some packages still use previous versions like Beta 5.0,...

like image 1
Sirwan Afifi Avatar answered Nov 06 '22 23:11

Sirwan Afifi