Visual Studio 2012 crashes when opening an ASP.NET MVC project with a cshtml open
By rickvdbosch
- 2 minutes read - 326 wordsA rather long title for this post, but that’s exactly what happened: when I opened an ASP.NET MVC 4 project with a cshtml view open, Visual Studio would crash with the error messages seen on the right. This would only occur if the first project I opened had a cshtml file open. When I opened another (type of) project first and then opened a project with a cshtml file open, the problem did not occur. Debugging Visual Studio with a new instance of Visual Studio (Inception anyone?) made things a bit clearer. (Part of) the exception information:
Source
WebEssentials2012
Message
Could not load type ‘Microsoft.Less.Core.LessMixinDeclaration’ from assembly ‘Microsoft.VisualStudio.Web.Extensions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
After searching around a bit, I found this blog post by Mads Kristensen: Web Tools 2012.2 and Web Essentials. This post talks about Web Tools 2012.2 and Web Essentials 2.5, and how an error can occur if you install Web Tools 2012.2 and don’t upgrade to Web Essentials 2.5. However, I do have Web Essentials 2.5.1 installed so this issue shouldn’t be the same as mine.
Although my situation didn’t match the one on Mads’s blog, I decided to install Web Tools 2012.2 just to see what the result would be. As it turned out, installing the Web Tools 2012.2 did solve the problem. Here’s why I think this solved it:
I had an older version of WebEssentials installed, which included specific functionality. This functionality was moved to Web Tools, and out of the new version of Web Essentials. When I updated to the new version of Web Essentials (without having Web Tools installed!), the functionality was no longer available in Web Essentials giving me the ‘Could not load type’ exception.
I’m not sure why the exception did not occur when I opened a different project first or if this is the exact reason of the exception occurring. I’ll contact Mads to share my findings, he might be able to reproduce this.
Hope this helps