Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Prevent Visual Studio Crash When Debugging MVC Web Applications

0.00/5 (No votes)
28 Aug 2014 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.

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!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here