Sunday, March 06, 2011

ThreadAbortException:Thread was being aborted in IIS 7

Recently i was developing a WCF web service in IIS 7 on Windows Server 2008 and started getting this exception quite weirdly. Weirdly in the sense that the exception was not consistently being reported at the same call stack.

My web service was using App_Data to store some application specific data which was also being added/modified/deleted during runtime.

After doing a lot of searching and study, the behavior of writing to the App_Data turned out to be the culprit. It is really hard to guess what may be wrong. In fact, I learnt that heavily modifying application subdirectory shuts down the appdomain.

Following are two references that explain this thing -

It seems that it has nothing to do with IIS 7 though and can happen even with IIS 6.


Paolo Antonucci said...

I really need to say that I love you! I have a WCF service hosted in IIS (not an ASP.NET application). This service would weirdly restart
After HOURS of debugging and googling with different keywords, I eventually googled ThreadAbortException and ended up on your page. It turns out that IIS hosted applications are instantly restarted whenever anything inside the 'bin' folder is modified (creating a new text document is enough), as this is considered a "configuration change".

This seems not to be logged anywhere (WAS logs in the Event Viewer, IIS website text logs, WCF log), and didn't show up in any reasonable Google search I could think of (about instance recycling).

Although this is not exactly what you are describing, your post was the one that took me to the solution! Thank you!

Sanjay Singh said...

Thank you Paolo. I am very glad that it helped you.