Global.asax中没有发射的发布版本 [英] Global.asax not firing for Release build

查看:272
本文介绍了Global.asax中没有发射的发布版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个应用程序的具有自动发送电子邮件提供了帮助台应该它遇到异常的一定水平的机制。一个特殊的例外,一个NullReferenceException,造成了一些问题,我认为它是由IIS回收和丢失会话所致。
为了证明这一点,我希望在应用程序启动登录/采空/回收并添加了一些code到Global.asax文件做到这一点。运行在调试模式日志消息写出来和一切似乎都很好。当我切换到发布版本,这将触发一个Web部署项目建在IIS配置的文件夹,问题就来了。

One of our applications has a mechanism for emailing our Helpdesk automatically should it encounter a certain level of exception. One particular exception, a NullReferenceException, is causing a few problem and I believe it is caused by IIS recycling and losing the session. To prove this I want to log when the application is started/stoped/recycled and have added some code to the global.asax file to do this. Running on Debug mode the log messages are written out and all seems well. The problem comes when I switch to Release build, which triggers a Web Deployment Project to build to a folder configured in IIS.

当我浏览到因为不创建日志文件并没有更新事件日志中ApplicationStart方法不被调用的应用程序。当我重新启动IIS同样的情况对于ApplicationEnd,即不创建日志。

When I navigate to the application the ApplicationStart method is not being called as the log file is not created and the Event Log is not updated. When I restart IIS the same happens for ApplicationEnd, i.e. not logs are created.

为什么工作了调试版本,但没有释放的?我一直在踢这个兜了几个小时,它的驾驶我疯了。

Why is it working for Debug builds but not Release ones? I've been kicking this around for hours now and it's driving me nuts.

在此先感谢

** :我不是100%肯定这是怎么回事,但现在看来是工作。我想,也许我们使用日志汇编可能不会被ApplicationStart是这样执行的时候,我删除了所有code和刚刚创建的方法中的文本文件,而不是加载。看哪,文件被创建!所以我加了一个if(记录仪!= NULL)类型检查,试图输出一些诊断,但什么也没有写出来。于是,我就一个try / catch并写了一个空白文件exception.txt如果有异常被抛出,但仍然没有创建文件 - 虽然生成事件日志和预期的日志文件!我很困惑! **

**: I'm not 100% sure what is going on but it now appears to be working. I thought that maybe the assembly we use for logging might not be loaded by the time ApplicationStart is executed so I removed all the code and just created a text file in the method instead. Behold, the file was created! So I added an if(logger != null) type checking to try to output some diagnostics but nothing was written out. So I tried a try/catch and wrote a blank file "exception.txt" if an exception was thrown but still no file was created - although the event log and expected log file were generated! I'm confused! **

推荐答案

我们有这个问题,缺少的 precompiledApp.config 文件是解决办法。没有它的Global.asax事件使用ISAPI筛选器IIS6下不火和的 rewritten.aspx 的方法例如记载在博客,codeville.net。我们使用的MSBuild至precompile网站在部署之前。

We had this problem and a missing PrecompiledApp.config file was the solution. Without it global.asax events did not fire under IIS6 using an ISAPI filter and the rewritten.aspx approach documented e.g. on blog.codeville.net. We use msbuild to precompile the site before deploying.

我们划伤我们的头在这一个了几个小时,当我们建立停止工作。原来同时强迫看家模式我已经删除从源头控制这个文件,因为我认为这是多余的。添加它放回解决了这一问题。

We scratched our heads over this one for a couple of hours when our builds stopped working. Turns out while in obsessive house-keeping mode I had removed this file from source control as I thought it was redundant. Adding it back in fixed the problem.

这篇关于Global.asax中没有发射的发布版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆