views:

431

answers:

3

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 generate 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

+1  A: 

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

womp
Read the question; I'm not using IIS. Is there any way to configure that in ASP.Net itself?
SLaks
I don't see anything in the question that indicates ISS being used or not. For the record, exactly how are you launching the ASP.NET application domain, if not via IIS?
Jeremy Seghi
You're right; that was only in the linked question. I'm launching the ASP.Net AppDomain by calling `ApplicationHost.CreateApplicationHost` in my EXE.
SLaks
SLaks - the functionality you're after is inside System.Web.HttpRuntime. I'm not sure you're going to have any luck modifying it, but you might try the approach in this thread: http://forums.iis.net/t/1121400.aspx
womp
I looked inside HttpRuntime, but I didn't see anything like that. I'll look at the thread.
SLaks
System.Web.Runtime contains the FileSystemMonitor. It's internal though (which explains why IIS can use it but you can't). I'll be very interested to see if you get it working.
womp
+1  A: 

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.

Paulo Santos
This sounds interesting. Can I distribute the templates with the program and run them at runtime? Also, can I get ASP.Net-style IntelliSense when editing the templates? (In Visual Studio)
SLaks
Yes, T4 templates are simple text files. No, not natively, that is. There are intellisense for T4 from 3rd parties, though.
Paulo Santos
However, T4 templates require Visual Studio to execute; I don't want to require Visual Studio on my end user's machines. Also, I use master pages, and I don't know how easily they would port to T4
SLaks
No, T4 doesn't require Visual Studio to run. But, like I said... it's far off in the development track.
Paulo Santos
It doesn't? Can you give me a source?
SLaks