Sunday, June 26, 2011

Windows Azure: WebRole.cs is NOT running in the same process as the website

WebRole.cs is running in WaIISHost.exe in local dev, and website is in w3wp.exe. This causes code running in the WebRole.cs having no access to the website's in memory classes/code, thus several confusing issues:
1. If you initialized something in Run/OnStart, it is actually not effective for the website.
2. The code running in WebRole.cs can not access the web.config file, as it is not run as a website.
When I tried to start a Quartz.NET scheduler, such an architecture caused many mysterious behaviors and issues for me. E.g., the scheduled job has a EF object that can not get its connection string (because it is in the web.config). And trying to run a scheduled job code in the website ondemand can not access the main scheduler (because it is in another process!). After I moved the initialization code for the scheduler into the Global.asax.cs, everthing starts working.

1 comment:

Anonymous said...

Wonderful, what a website it is! This website gives helpful facts
to us, keep it up.

my web page :: www.freearticlepublishing.org
My web page > http://www.langocha.fr/wiki/index.php?title=Utilisateur:OscarObri