c# - Can we use global.asax file in DotNet class library projects -


can use global.asax file in .net class library projects? because have not seen anywhere global.asax file can used web based applications.

the code of global.asax file being complied , being called .net framework when application starts. want use similar kind of functionality class library i.e. when class library being loaded in memory application_start of global.asax file of class library called.

i know can used using static constructor want utilize global.asax this.

any suggestions/comments highly appreciated..

thanks

the global.asax file feature of asp.net appliations. not available in dlls (class library projects).

there no standard way (using c#) of running code on assembly-load, though clr seems have such feature. have @ this question more information , ideas. example, 1 answer mentions tool called injectmoduleinitializer, run post-build step inject module initializer method .net assembly.

here's short excerpt blog post introducing injectmoduleinitializer:

one feature of clr not available in c# or vb.net module initializers (or module constructors). module initializer global function named .cctor , marked attributes specialname , rtspecialname. run when module (each .net assembly comprised of 1 or more modules, typically one) loaded first time, , guaranteed run before other code in module runs, before type initializers, static constructors or other initialization code.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -