开发者

Prevent ASP.Net AppDomain Unload

开发者 https://www.devze.com 2022-12-17 02:23 出处:网络
As described here, I\'m writing a WinForms GUI that is run in an ASP.Net AppDomain. However, whenever Web.config or the bin folder is modified, ASP.Net unloads the AppDomain, and the entire program d

As described here, I'm writing a WinForms GUI that is run in an ASP.Net AppDomain.

However, whenever Web.config or the bin folder is modified, ASP.Net unloads the AppDomain, and the entire program dies.

Is there any way to prevent this?

2nd EDIT: In my EXE, I create the AppDomain by calling ApplicationHost.CreateApplicationHost and pass it a type in my EXE that launches the GUI.

EDIT: I'm already aware that this is a horrible design.

Does anyone have a sane alternatives?

The program tracks accounts for a non-profit organization in a typed dataset.

It needs to send bills by email, and I'm using ASPX files to genera开发者_Go百科te the emails. (I'd rather not change that, unless there's a very nice alternative; the templates have already been written)

The email templates are ASPX files that are deployed in a subfolder; that subfolder becomes the ASP.Net application and has the executable in its bin directory for ASP.Net to load all of my code into its AppDomain.

The typed dataset must be accessed by both the UI and the ASPX files, and I don't want to download the data from SQL server twice


This is core to ASP.Net - if the web.config is changed, the AppDomain is recycled. If the machine.config is changed, all AppDomains are recycled.

However, you can disable this. Turn on "Disable Recycling on Configuration Changes" for the application pool you are interested in in the IIS control panel.

alt text http://img138.imageshack.us/img138/9938/iisdisablerecycle.png


See this question: How to prevent an ASP.NET application restarting when the web.config is modified?


I've noticed that your first question is dated Oct 29. I know it's far off on the development track...

But just out of curiosity: Why not use T4 templates?

It's simple, fast, you can edit pretty much like an ASPX page, and it runs in whatever AppDomain you are.

0

精彩评论

暂无评论...
验证码 换一张
取 消