Adding CMSUseAutomaticScheduler app setting caused SchedulingExecutor exception

Al Burns asked on February 5, 2020 10:47

Hi.

Our client has seen an issue with scheduled publishing of content not happening. This issue looks to be caused by the CMS admin site going to sleep through inactivity and not running the Content Publishing scheduled task for the site. I found the following article that highlights this issue - https://www.mcbeev.com/Blog/November-2019/Kentico-MVC-Quick-Tip-Fix-Scheduled-Content

I added the CMSUseAutomaticScheduler app setting with a value of "true" to the web.config file for the CMS site as recommended in the aticle, but I then noticed a number of scheduled tasks throwing exceptions. Here is the stack trace for the Content Publishing task as an example:

Message: Could not load file or assembly 'CMS.Reporting.Web.UI' or one of its dependencies. The system cannot find the file specified.

Exception type: System.IO.FileNotFoundException
Stack trace:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at CMS.Base.ClassHelper.GetAssemblyInternal(String assemblyName)
at CMS.Base.ClassHelper.GetClassInternal(String assemblyName, String className)
at CMS.Scheduler.SchedulingExecutor.GetTaskExecutionDelegate(TaskInfo taskInfo)
at CMS.Scheduler.SchedulingExecutor.ExecuteTaskInternal(TaskInfo taskInfo)

Removing the app setting has resolved this and the tasks are now running correctly. Can anyone explain what the problem here is and what I can do to fix it so that I can use the app setting to resolve my original issue?

Many thanks.

Recent Answers


Dmitry Bastron answered on February 5, 2020 14:56 (last edited on February 5, 2020 14:57)

Hi,

I literally had this problem a couple of days ago and found the following solution. I'm assuming you probably have Kentico MVC with different domains for CMS admin and MVC applications.

If you look at web.config definition there are multiple scheduler related keys. All you need to do is:

  • Add (key="CMSUseAutomaticScheduler" value="true") to your CMS (not MVC) web.config
  • Add (key="CMSSchedulerURL" value="https://domain/cmspages/scheduler.ashx") to your CMS (not MVC) web.config with a full path to CMS web application.
1 votesVote for this answer Mark as a Correct answer

Al Burns answered on February 5, 2020 16:25

Hi Dmitry, thanks for your response.

I added the first key and all hell broke loose, but I didn't have the 2nd key so I'll try adding that.

I found further documentation that confirmed a Windows service needs to be installed & running - https://docs.kentico.com/k12sp/configuring-kentico/scheduling-tasks/installing-the-scheduler-windows-service Did you have to do that?

Many thanks.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on February 5, 2020 17:17

Windows service would be required if you want to run tasks in a separate service (Use external service checkbox for a scheduled task).

Personally, I'm not using it because my environment is in Azure configured as Web Applications (so I technically can't run any Windows services there). It works fine for me without external service and I use another checkbox - "Run task in separate thread".

0 votesVote for this answer Mark as a Correct answer

Brian McKeiver answered on February 6, 2020 02:05

Al, I can confirm that Dmitry is correct, you don't need the Windows service installed to run tasks via the automatic scheduler. The original stack trace you have makes me think that the automatic scheduler is actually working, but the process of running the scheduled tasks is erroring. Are you sure the bin directory on the CMS app has the correct set of Kentico dlls for your target deployment (the server or App Service it is running on)?

Glad you found my blog post at least a little helpful!

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on February 6, 2020 10:22

Brian, what I found also, it looks like that MVC version (when you have 2 applications and 2 separate domains for CMS and frontend), the CMS by default combines the wrong URL to ping the scheduler: it seems to be using site main domain (or presentation URL) and therefore tries to ping MVC application instead and that's causing errors.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.