Monday, June 18, 2007

Global.asax and PrecompiledApp.config

I spent the better part of the day and a bit more a few days back trying to figure out this problem!

I have put some exception handling int he application_error event of my global.asax, and everything ran smoothly on my dev and staging box. For some reason, I could not get our production environment to handle the exception handling for our unhandled exceptions. At first I thought it was our logging mechanism, but after a few tests, we figured the code was ok.

We looked at permissions for the account running the site, but there was nothing wrong there. Finally there was a link that a co-worker gave me that suggested that the PrecompiledApp.Config be removed from the root of the application. As it turns out, that file has been missing (due to some deployment issues), so we put it back in and it started to work. The application_error event was finally firing. I can't figure out exactly why the config file is needed, but it is for precompiled applications. Hope it helps someone!

3 comments:

Anonymous said...

Today I faced same issue related to PrecompiledApp.config.

I removed from dev and staging server as a part of cleanup task and found that application was throwing weird exception, in my case it was throwing exception,
"Unable to cast object of type 'System.Web.HttpApplication' to type 'Microsoft.Practices.CompositeWeb.WebClientApplication"

There is no official document found from microsoft about deployment and considering PreCompilation do's and don't

Phew! I found here in this blog and fix it...Dev is working fine, let's see how staging will behave?!!!

Anonymous said...

Last week I faced with a similar problem in one of our projects. Lucky to find this blog!

Anonymous said...

Even two years later, this post avoid me asylum, Thanks !!!