Search code examples
asp.netwindowsiis-7web-config

Stop ASP.Net from recycling app pool due to "changes to the bin"


Greetings, I have a large .Net web app which runs on a farm of blades with the code base on a NAS. Every once in a while slight fluctuations in the response time of the nas cause .NET to think that something in the bin has changed and kick off a recycle of the app pool. No change has actually occurred. Is there a way to disable .Net's monitoring of changes to the bin?


Solution

  • This will put an end to it. Now you must do iisreset to recycle your app pool.

    'This is supposed to turn off the monitoring for directory deletes
    'See https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=240686
    'This incurs the penalty of an IISRESET or manually restarting the containing AppPool after every upgrade.
    Dim pi As PropertyInfo
    Dim o As Object
    Dim m As MethodInfo
    pi = GetType(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic Or BindingFlags.Public Or BindingFlags.Static)
    o = pi.GetValue(Nothing, Nothing)
    m = o.GetType().GetMethod("Stop", BindingFlags.Instance Or BindingFlags.NonPublic)
    m.Invoke(o, New Object() {})