Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. Problems Running Sharepoint Custom Timer Jobs

Problems Running Sharepoint Custom Timer Jobs

Scheduled Pinned Locked Moved SharePoint
helpsharepointcomsysadmincareer
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saanj
    wrote on last edited by
    #1

    Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi

    S B E 3 Replies Last reply
    0
    • S saanj

      Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi

      S Offline
      S Offline
      saanj
      wrote on last edited by
      #2

      Hello everybody, Problem solved :-O. I deployed the solution(wsp) in the central administration site. I also activated the feature in the centreal administration site which caused the problem. In the execute method, it was repeatedly showing ArgumentNullException. So, I just deactivated the feature from the central administration site and activated it in one of the sharepoint site. The timer job started and didn't throw any error int the Sharepoint Timer Job Status and in the Windows Event Viewer's error log. I really did a silly mistake which caused me to be puzzled over few extra hours. Well, I was also able to debug the Timer Job class by doing the following things: (i) Deploying the pdb file to GAC. (ii) Attaching the class file with the two processes simultaneously: w3wp.exe and owstimer.exe. I am happy and relaxed now. If anyone of you had faced this problem, steps and descriptions mentioned above may help. :-\ Regards Saanj

      Either you love IT or leave IT...

      1 Reply Last reply
      0
      • S saanj

        Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi

        B Offline
        B Offline
        Bijayani
        wrote on last edited by
        #3

        When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. Steps To create a custom timer job: 1. We need to create a class that inherits the SPJobDefinition Class. Then we need add the constructor s and the Execute () method. namespace TestTimerJob { public class CustomTimerJob : SPJobDefinition{ public CustomTimerJob (): base(){ } Hope you find this tips useful and of assistance. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^] Thanks, Bijayani

        S 1 Reply Last reply
        0
        • B Bijayani

          When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. Steps To create a custom timer job: 1. We need to create a class that inherits the SPJobDefinition Class. Then we need add the constructor s and the Execute () method. namespace TestTimerJob { public class CustomTimerJob : SPJobDefinition{ public CustomTimerJob (): base(){ } Hope you find this tips useful and of assistance. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^] Thanks, Bijayani

          S Offline
          S Offline
          saanj
          wrote on last edited by
          #4

          Thanks Bijayani. :)

          There is no foolish question, there is no final answer...

          1 Reply Last reply
          0
          • S saanj

            Hello everybody, I have created a Custom Timer Job by extending SPJobDefinition class. The code is given below: public class TaskLoggerJob : SPJobDefinition{ /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> public TaskLoggerJob () : base(){ } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="service">The service.</param> /// <param name="server">The server.</param> /// <param name="targetType">Type of the target.</param> public TaskLoggerJob (string jobName, SPService service, SPServer server, SPJobLockType targetType) : base (jobName, service, server, targetType) { } /// <summary> /// Initializes a new instance of the TaskLoggerJob class. /// </summary> /// <param name="jobName">Name of the job.</param> /// <param name="webApplication">The web application.</param> public TaskLoggerJob (string jobName, SPWebApplication webApplication) : base (jobName, webApplication, null, SPJobLockType.ContentDatabase) { this.Title = "Task Logger"; } public override void Execute(Guid targetInstanceId) { foreach (SPSite siteCollection in this.WebApplication.Sites) { WarmUpSiteCollection(siteCollection); siteCollection.RootWeb.Dispose(); siteCollection.Dispose(); } } private void WarmUpSiteCollection(SPSite siteCollection) { WebRequest request = WebRequest.Create(siteCollection.Url); request.Credentials = CredentialCache.DefaultCredentials; request.Method = "GET"; WebResponse response = request.GetResponse(); response.Close(); } } I have successfull deployed and activated the web solution package file. The job is also there in the Timer Job Defeinition list. It runs in one minute and everytime it runs it throws the following error in event log: The Execute method of job definition MOSSTaskLoggerJob.TaskLoggerJob (ID 342cb188-8b01-4c53-b709-5750ac5a7062) threw an exception. More information is included below. Value does not fall within the expected range. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. I checked the details in the sharepoi

            E Offline
            E Offline
            elizas
            wrote on last edited by
            #5

            When we want to run a task (like sending emails or deleting the list items etc. . . ) in Daily basis or in Hourly basis then we can use a Timer job to this task .To see the timer job you can move to the Central Administrations then click on the operations tab, then in the Global Configuration section you can see the Timer job status and timer job definition. In timer job definition you can get the details of the timer job i.e. the title , the web application to which it is attached and the schedule type i.e. Daily, Weekly or hourly basis. To get the status of the timer job go to the timer job status, here you can view status. http://www.mindfiresolutions.com/How-to-create-a-Custom-Timer-job-in-SharePoint-957.php[^]

            Cheers, Eliza

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups