I am building up a Unity container in the Global Application_Start event and then stashing it away in a static variable which is then made globally available via a method on an interface implmented by the GLobal class and is then available, correctly cast on the HttpContext.Current.ApplicationInstance , which works well for a time. When the application pool recycles, the static variable is cleared out, The Application_Start event, is seemingly not reexecuted and the container doesnt have any of the registrations it started out with.
Has anyone else come across this issue? and were able to resolve it?
I guess that you are using classic ASP.NET web forms. In that case I would advocate for using the
HttpApplicationState(available viaHttpContext.Current.Application) to store the container.Have a look at the comments to Chris Tavares’ answer to this question. Chris was the chief maintainer for Unity. He knows what he is talking about.