2

I've developed an MVC3 web site using VS2010 which works great. I recently upgraded my dev environment to VS2012 RTM. I'm now unable to run the web site in the debugger without crashing the development web server.

WebDev.WebServer40.exe has stopped working

I see one of two similar stack traces in VS2012:

Firstly, an AccessViolationException:

mscorlib.dll!System.StringComparer.GetHashCode(object obj) + 0xc bytes  
mscorlib.dll!System.Collections.Hashtable.GetHash(object key) + 0x10 bytes  
mscorlib.dll!System.Collections.Hashtable.InitHash(object key, int hashsize, out uint seed, out uint incr) + 0xf bytes  
mscorlib.dll!System.Collections.Hashtable.Remove(object key) + 0x38 bytes   
System.dll!System.Collections.Specialized.NameObjectCollectionBase.BaseRemove(string name) + 0x2e bytes 
System.Web.dll!System.Web.SessionState.SessionStateItemCollection.Remove(string name) + 0x56 bytes  
System.Web.dll!System.Web.SessionState.HttpSessionStateContainer.Remove(string name) + 0xc bytes    
System.Web.dll!System.Web.HttpSessionStateWrapper.Remove(string name) + 0xf bytes   
Dive7.Site.dll!Dive7.Site.D7WebViewPage<object>.IsAdmin.get() Line 56 + 0x19 bytes  C#

Secondly, a NullReferenceException:

mscorlib.dll!System.StringComparer.GetHashCode(object obj) + 0x33 bytes 
mscorlib.dll!System.Collections.Hashtable.GetHash(object key) + 0x10 bytes  
mscorlib.dll!System.Collections.Hashtable.InitHash(object key, int hashsize, out uint seed, out uint incr) + 0xf bytes  
mscorlib.dll!System.Collections.Hashtable.Remove(object key) + 0x38 bytes   
System.dll!System.Collections.Specialized.NameObjectCollectionBase.BaseRemove(string name) + 0x2e bytes 
System.Web.dll!System.Web.SessionState.SessionStateItemCollection.Remove(string name) + 0x56 bytes  
System.Web.dll!System.Web.SessionState.HttpSessionStateContainer.Remove(string name) + 0xc bytes    
System.Web.dll!System.Web.HttpSessionStateWrapper.Remove(string name) + 0xf bytes   
Dive7.Site.dll!Dive7.Site.D7WebViewPage<object>.IsAdmin.get() Line 56 + 0x19 bytes  C#

The exact one that occurs seems to be random.

To the best of my knowledge, all I did was install VS2012, reboot, then open my VS2010 solution in the new version of VS, watch it say that the upgrade was successful, and press F5.

I'm out of ideas. Can anyone suggest what might be going on?

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742

2 Answers2

2

Please read section "Installing ASP.NET MVC 4 breaks ASP.NET MVC 3 RTM applications" from link http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815. Follow setps "Required updates" and let me know if this error still repros.

Anand
  • 1,440
  • 8
  • 11
  • Thanks for your answer. However I didn't explicitly ask to be upgraded from MVC3 to MVC4 -- instead, I just upgraded the sln and csproj files to VS2012. My project references `System.Web.Mvc.dll` 3.0. Did I miss something at the link you gave? – Drew Noakes Sep 28 '12 at 00:23
  • 1
    When you install VS2012, it installs MVC 4. You need to follow steps to make MVC 3 apps work side by side with MVC 4 on that machine. – Anand Sep 28 '12 at 21:04
  • Thanks, I missed that section. Thank you very much. – Drew Noakes Oct 01 '12 at 12:23
0

As pointed out by Anand, you must make some manual changes to an MVC3 app when you open it in VS2012, as the installation of VS2012 causes MVC4 to be installed as well. These changes allow side-by-side operation:

In Web.config:

<appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>

Then edit your MVC project's .csproj file. Replace these lines:

<Reference Include="System.Web.WebPages"/> 
<Reference Include="System.Web.Helpers" />

(they may look like this):

<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>..\..\..\..\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
    <SpecificVersion>False</SpecificVersion>
</Reference>

With these lines:

<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/> 
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

Taken from the MVC4 Release Notes.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742