Skip to content
December 22, 2012 / pauldundon

Running Startup Code in .NET Libraries

The problem: You have written a .NET Class Library for use in the context of a web application and want to run some code at startup time to initialise state within the library.

Possible solution: use the System.Web.PreApplicationStartMethod attribute

Limitation: This will only take effect when the library is loaded by IIS.


<Assembly: System.Web.PreApplicationStartMethod(GetType(Startup), "DoStartup")> 
Public Class Startup
  	Public Shared Sub DoStartup()
   		' Startup code goes here
  	End Sub
End Class 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: