Application_Start not called in global.asax. Why?

无人久伴 提交于 2019-12-13 03:52:46

问题


In my global.asax I have the following code:

public static bool Was = false;

protected void Application_Start(object sender, EventArgs e)
{
    Was = true;
}

When I open a page and look at the Was variable, it's still false. What gives? (Note: the variable isn't used anywhere else, I made it just for this test case)

Update: I just found out that my whole global.asax file is getting ignored. How can this be?

Update 2: Sorry, it does get into play after all. But there's extra weirdness there. So much extra weirdness, that I've opened a new question for that.


回答1:


OK, so the problem was that I had not installed Visual J# redist which is required by my app. However the manifestation of this problem was really weird. I've opened another question for that:

When does .net check for assembly dependencies?

In essence I guess the lesson is: when your application lacks some dependant assembly, don't expect it to fail outright. Expect some method calls to start throwing FileNotFoundException.



来源:https://stackoverflow.com/questions/3701304/application-start-not-called-in-global-asax-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!