Application_Start not called in global.asax. Why?

2019-08-31 23:50发布

问题:

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.