You should move your code to the Global.asax file in the Application_Start method :
protected void Application_Start(object sender, EventArgs e)
{
//your initialization code
}
Update :
As noted in comments, this is not a solution to the problem as Application_Start
is also called on first request.
So it seems that the only solution is to find a way to call a web page as soon as IIS is restarted.
Here are some suggestions from another website :
One tricky solution to this problem
can be adding your website to search
engines. Search engines crawl pages
frequently. So, they will hit a page
of your website resulting in
Application_Start and thus the service
will get up and running.
Another idea is to register your
website to some traffic or
availability monitoring services.
There are lots of web services which
keep an eye on your website and checks
whether it is alive and the
performance is satisfactory. All these
services hit your web site pages and
then collect the statistics. So, by
registering in such services, you can
guarantee your web application is
alive all the time.
I'd go with the monitoring service solution, with services such as (I didn't try them) :
http://www.montastic.com/
http://www.siteuptime.com/