Click here to Skip to main content
15,887,335 members
Articles / Web Development / ASP.NET
Tip/Trick

Prevent Visual Studio Crash When Debugging MVC Web Applications

Rate me:
Please Sign up or sign in to vote.
4.93/5 (5 votes)
28 Aug 2014CPOL1 min read 15.1K   6   1
Here is a tip for making sure that debugging your MVC website does not cause Visual Studio to crash when using IIS7 to host the site in your development environment: Don't use more than one worker. process in your Application pool.

Introduction

Prevent Visual Studio crashes when working with MVC web applications.

Image 1

Background

Recently, I was trying to debug a MVC 5 web application in Visual Studio 2012. However, every time I would try to debug it, Visual Studio would crash. If I put the build into release mode, then I could run the application (but not debug it). I was using IIS7 to host the site in my local development environment. I realized that the issue happened when I was working on a production issue and it came to me that I had been experimenting with running the application pool as a web garden, which is to say more than 1 worker process.

The Cause

The cause is, the best I can determine the fact that I had the application pool set to have 7 worker processes and had several users logged into the site. When debugging the web application, Visual Studio has to attach to the work process. When there is more than one running, Visual Studio seems to not know which one to attach to, or it seems to attach to the wrong one which results in an error condition that causes Visual Studio to crash.

The Solution

To resolve the issue, I went into IIS 7, found the application pool in question under application pools and went into advanced properties. Find the setting for Maximum worker processes. In my case, I had it set to 7. I set it back to 1, restarted the application pool and went into Debug mode and voila! Debugging successful!

Image 2

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
United States United States
Software Engineer IT Team lead with over 11 years application development experience, over 15 years IT experience.

Proficient Technologies / languages
Experienced in .NET, C#, MVC, Web Services, Windows Services, Entity Framework, SQL, ADO.NET and more.

Dabbles in
Android, java, Linux and most things computer related.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Humayun Kabir Mamun28-Aug-14 18:48
Humayun Kabir Mamun28-Aug-14 18:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.