I was trying to make use of the custom service appliaction which I got from the source, http://msdn.microsoft.com/en-us/library/gg193964.aspx, to make it automated by associating with a timer job. When I'm running the application, the timer job is not hitting. When I try to debug the code it is not hitting at all. Please help me out with this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using CriticalPath.SharePoint.Samples.WingtipCalculator;

namespace SampleTimerJob

   public class SampleJobDefinition : SPJobDefinition
       public const string JobName = "SimpleJobDefinition"; 

        public SampleJobDefinition() : base() { }

        public SampleJobDefinition(SPService svcApp) :
            base(JobName, svcApp, null, SPJobLockType.Job) 
            Title = "Simple Job Definition";

        public override void Execute(Guid targetInstanceId)
          //SPWebApplication webApp = this.Parent as SPWebApplication;

            SPSite mySite = new SPSite("http://ussecavdspdwk09/tax");
            SPWeb myWeb = mySite.OpenWeb();

            SPServiceContext mySiteContext = SPServiceContext.GetContext(mySite);
           // SPServiceContext mySiteContext = SPServiceContext.GetContext(mySite);
                CalcServiceClient client = new CalcServiceClient(mySiteContext);



  • I can't answer your question as I don't work with timer jobs that often, but you do need to dispose of your myWeb and mySite objects. The recommended approach is to open them in a using {} block so that they are disposed automatically – Dave Wise Feb 8 '12 at 23:21
  • What version of SharePoint and what version of Visual Studio? – Dave Wise Feb 8 '12 at 23:25

shot in the dark - 1) Does your timer job have a defined schedule? and 2) are you restarting the Timer Service after deploying updates to your code?

This post might help a bit more with the Timer Job itself


my guess:

you are attaching your debugger to the w3wp process (explicitely via debug -> attach to process for sp2007/sp2010, or by hitting f5 for vs2010/sp2010).

that is not the right process. Try attaching it to the owstimer, that is the process that the job runs in. press debug -> attach to process -> owstimer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.