Reputation: 6685
I have MVC3 web application running under IIS 7. During initialization in global.asax application scans all the assemblies returned by BuildManager.GetReferencedAssemblies(), and all the types (Assembly.GetTypes()) in those assemblies in order to do initialization stuff.
From time to time the application stops working properly - it behaves as if the initialization never happened or some types were omited during startup. Once the application enters this failed state (I think it happens after the pool is recycled) it stays that way until restarted by:
I noticed that 1. always helps, but 2,3,4 works indeterministically - at least as far as I can say because the nature of the problem is not deterministic - application crashes only after some scheduled recycles. What is the difference between 1 and 2,3,4 from the point of view of global.asax code and access to loaded assemblies?
Oh, the application runs as a sub-application (subfolder in IIS sites tree) if it changes anything.
Upvotes: 4
Views: 4804
Reputation: 64943
I believe your problem could be solved by saving some state information so application can be aware about if its startup was successful.
Whenever application checks there's something incorrectly initialized, it should re-initialize it or throw an exception and restart application.
It's really hard to give you an solution, but summarizing you can do this:
Directly answering to your question:
Basically, any of these actions produces the same result.
Have you tried to do an IIS reset - iisreset /restart
command -? This should release any locked resource and stop any unwanted loop, thread or whatever thing crashing your application.
Upvotes: 1