Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Scenario: Many users (between 10 & 100) are browsing the site, and as they browse, URL Rewrite / Redirect rules are being toggled. The application crashes at random times with the following message logged in the exception log table (we use Enterprise Library Exception framework):

Common Language Runtime detected an invalid program


An exception of type 'System.InvalidProgramException' occurred and was caught.  ------------------------------------------------------------------------------  07/12/2011 12:02:20  Type : System.InvalidProgramException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089  Message : Common Language Runtime detected an invalid program.  Source : App_Web_wvjyf0pr  Help link :   Data : System.Collections.ListDictionaryInternal  TargetSite : System.Web.UI.WebControls.Panel __BuildControlpnlSearchResult()  Stack Trace :    at ASP.my_underscore_seperated_page_name_aspx.function() at ...

Server: Windows 2008R2

.Net: 3.5

WebServer: IIS7

Oddly, on enabling failed request tracing on IIS to capture status codes 400 - 506, no requests/responses were captured.

I understand every time a rule is toggled, Web.config is modified. Can modifiying Web.config too frequently be a cause?

Rules in Web.Config look like the follows:

<rule name="Redirect Rule For Page Name" enabled="false" stopProcessing="true">
  <match url="PageName" />
    <add input="SiteFolder/SubFolder/PageName.aspx" pattern="^(SiteFolder/)([^.])+(PageName.aspx)$" />
  <action type="Redirect" url="http://www.MySite/SiteFolder/NewPage.aspx" appendQueryString="false" />

Any help is appreciated.

share|improve this question

Pretty sure that every time a web.config file is touched, the AppDomain for it is restarted.

It's plausible to me that you could be getting requests picked up by an AppDomain that's shortly thereafter aborted and the app cleaned up.

Cue Scott:

share|improve this answer
Does this mean the rules shouldn't be enabled / disabled when the application is being used? Restarting app domain would still be alright, if the .NET guaranteed that the application would respond to all requests correctly. What we also observed was once the user got the CLR detected invalid program error, it did not go away until we manually restarted the app pool for the site. – user162272 Jul 14 '11 at 4:08
If an app's going away, it's not going to respond to all requests correctly (same deal with recycling). If you mean "fail gracefully", that'd be my preference too - I don't know why it isn't, or wouldn't, except that too many changes could mangle something fundamental (or external things could mangle something, like AV). – TristanK Jul 14 '11 at 7:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.