4

I have Quartz.Net integrated for Scheduler job in my ASP.Net application.

But it is not working automatically and seems that it got stopped when IIS is recycling Application Pool. But fires when we send a request to server.

After reading IIS app pool recycle + quartz scheduling I am trying to configure the same in IIS 7.5 server for resolving the same.

<serviceAutoStartProviders> 
   <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" /> 
</serviceAutoStartProviders> 

However PreWarmCache class has been defined in my website and kept all logic, since it uses template from website pages.

How can I define this class from website in type? What would be the value for MyAssembly ?

I can use assembly name if my project is web application.

I created as website. So what could be the value or how should I configure that section?

Note: PreWarmCache is placed under App_Code directory

Community
  • 1
  • 1
Deepak
  • 195
  • 3
  • 6
  • 17
  • Is `PreWarmCache` type placed under `App_Data` directory and in a namespace? – Karel Frajták Sep 04 '13 at 09:40
  • @KarelFrajtak, it is placed under App_Code directory – Deepak Sep 04 '13 at 09:42
  • My first move would be to try to use "App_Code" as assembly (provided PreWarmCache is in App_Code) but it seems trickier, see http://stackoverflow.com/q/9520231/1236044 – jbl Sep 04 '13 at 09:43
  • I would try to run the app and at some place dump the `PreWarmCache.GetType().FullName` to debug window or to web page and use the value. – Karel Frajták Sep 04 '13 at 09:44

2 Answers2

0

It is highly recommended that you do not use Quartz.NET in a web application. The application pools can, and do, reset. While they can be scheduled to recycle at certain times it's still possible for them to recycle at any time. This creates unpredictable behaviour and will be difficult to track down.

I highly recommend creating a Windows Service to handle your Quartz.NET tasks. It will be more predictable, easier to debug, and decoupled from your web application. This will remove the complexity of trying to keep the application pool on all the time to run a service.

If you still want to use Quartz.NET in your web application then this SO question may help.

Community
  • 1
  • 1
Dustin Venegas
  • 760
  • 1
  • 7
  • 16
0

This has nothing to do with Quartz.Net, but is to do with the IIS server recycling the application pool after a period of inactivity.

I have the same problem, but all I am trying to do is cache data.

So I need to do the following in my applicationHost.config file:

<serviceAutoStartProviders> 
   <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" /> 
</serviceAutoStartProviders> 

This then call a function that populates an XML document and stores it as a lookup table in the cache to be used as and when needed.

And the problem is that if I use the AssemblyQualifiedName attribute it returns the following for my class:

MyApp.PreWarmCache, App_Code.<#########>, Version=0.0.0.0, Culture=neutral, PublickKeyToken=null

Where the ######### are, is changed each time the code is compiled.

I do not want to separate this into a DLL, as that would incur having to replicate the code.

So the question is still the same.

Can I/we provide an explicit assembly name for a dynamically compiled ASP.NET website's App_Code classes?

Fixed it now, taken code out into a separate assembly, compiled added reference, now all complete.

gilesrpa
  • 969
  • 1
  • 12
  • 35