.net - How do I force loading of a specific assembly into every application domain of an MVC 2 application? -
i have loosely coupled code depends on specific assembly being loaded current application domain:
assembly assembly = appdomain.currentdomain.getassemblies().where( candidateassembly => candidateassembly.fullname.startswith("microsoft.windowsazure.serviceruntime")).singleordefault();
and code executed inside mvc 2 application , yields null
reference because assembly not loaded current application domain. call code assembly, introduce strong dependency of application code on assembly , no longer have loose coupling.
i need force iis (or whatever else) load assembly application domain before code runs. tried write implementation of ihttpmodule
, list in web.config, doesn't help.
so far tried add assembly under <system.web><compilation><assemblies>
, looks works, i'm not sure whether it's reliable.
how force loading specific assembly application domain without introducing dependency in code?
this wrong way , can cause serious timed bugs.
the setting affects asp.net compilation, forces loading assembly when asp.net views compiled , compiled @ once - either on first request view or during in-place precompilation process if latter setup. anyway there moment of time ofter no asp.net view needs compiled.
now there's iis apppool automatic recycle every 29 hours. when pool recycles starts new worker process , process starts hosting site payload. what's important asp.net views don't change during process , need not recompiled , compilation process not invoked , assemblies listed in <system.web><compilation><assemblies>
not forcibly loaded.
so thing looks working until 29 hours pass , falls apart.
a better solution needed. setting in <appsettings>
saying whether azure runtime should available. if setting set, code can make first call code inside azure runtime assemblies , make them load. if setting not set doesn't try call code.
Comments
Post a Comment