2

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

Community
  • 1
  • 1
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964

3 Answers3

3

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

womp
  • 115,835
  • 26
  • 236
  • 269
  • Read the question; I'm not using IIS. Is there any way to configure that in ASP.Net itself? – SLaks Jan 20 '10 at 00:46
  • 1
    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 S Jan 20 '10 at 00:56
  • 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 Jan 20 '10 at 01:02
  • 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 Jan 20 '10 at 01:04
  • I looked inside HttpRuntime, but I didn't see anything like that. I'll look at the thread. – SLaks Jan 20 '10 at 01:05
  • 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 Jan 20 '10 at 01:07
2

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

Community
  • 1
  • 1
Bryan
  • 8,748
  • 7
  • 41
  • 62
1

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.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
Paulo Santos
  • 11,285
  • 4
  • 39
  • 65
  • 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 Jan 20 '10 at 01:12
  • Yes, T4 templates are simple text files. No, not natively, that is. There are intellisense for T4 from 3rd parties, though. – Paulo Santos Jan 20 '10 at 01:23
  • 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 Jan 20 '10 at 01:43
  • No, T4 doesn't require Visual Studio to run. But, like I said... it's far off in the development track. – Paulo Santos Jan 20 '10 at 02:05
  • It doesn't? Can you give me a source? – SLaks Jan 20 '10 at 03:23