New thread in ASP.NET app can't see web.config appsettings'm
Inside my ASP.NET app, I have a long running-process that I launch in a new thread. However, it throws a null reference exception when it tries to access the appsettings in my web.config. I know that the problem is not in my code because when I don't launch in a new thread, everything wor开发者_开发知识库ks fine.
Any suggestions?
Thanks, Dan
If you dont mind a workaround then try this.
If you have small set of appsetting information then load the app setting in to memory on application start event and then pass that info as initialization values for the thread. if web.config changed, application automatically resets.
I had smiler situation and managed to solve with above workaround.
I'm not an ASP.NET expert, so I don't know the intricacies of how the application settings are loaded, but one solution is to just pass the data from your app settings to your long running process when you start it instead of reading your app settings from the thread. This is a better design anyway as now your thread is decoupled from the app settings.
精彩评论