We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

View Complete Thread
  • Re: System.Threading.ThreadAbortException when executing remote web service

    Apr 02, 2008 04:16 PM|lethargicgeek|LINK

    This may or may not be relevant... but are you modifying any files/directories in your application folder at runtime?

    In .Net 2.0 and later, the AppDomain is restarted whenever the file structure is heavily modified.  This causes all threads that do not wrap up in a timely fashion to be aborted.  Meaning, if your thread is fast enough, it won't be touched.  This is different than .net 1.1 where it was only the web.config and bin files that were monitored. 

    I myself was frustrated in figuring out why I could parse though a 100k file fine but my application threw ThreadAbortExceptions on a 500k file.  I killed hours playing with timeouts and configs before finding the solution. 

     Solution I used to disable File Monitoring:
    (requires using System.Reflection)

    PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
    object o = p.GetValue(null, null);
    FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
    object monitor = f.GetValue(o);
    MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
            m.Invoke(monitor, new object[] { });


    Two good references on the problem:

    The formal Complaint:

    Guy Forsyth Discussing the problem


    Hopes this helps someone...


    troubleshooting threadabortexception appdomain timeout