Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
                client.AddTask(mySite.Url);


        }

    }




}
share|improve this question
    
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
add comment

2 Answers 2

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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