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

This is really weird.

The exception is thrown in the FeatureActivated event exactly in the line job.Update(). There is no way to debug any further because that method is from the framework. Maybe I am missing to set more properties in the instantiation of the object??

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
            {

                // Get an instance of the SharePoint farm.
                SPFarm farm = SPFarm.Local;

                // Get an instance of the service.
                var results = from s in farm.Services
                              where s.Name == "SynchronizationUserAccessListJob"
                              select s;

                SPService service = results.FirstOrDefault();

                // Remove job if it exists.
                if (service != null)
                {
                    DeleteJob(service);
                }

                // Create the job.
                SynchronizationUserAccessListJob job = new SynchronizationUserAccessListJob();


                // Create the schedule so that the job runs hourly, sometime 
                // during the first quarter of the hour.
                SPHourlySchedule schedule = new SPHourlySchedule();
                schedule.BeginMinute = 0;
                schedule.EndMinute = 5;
                job.Schedule = schedule;
                job.Update();            
            }




 public SynchronizationUserAccessListJob() : base() 
        {
            this.Title = "SynchronizationUserAccessListJob";
        }

        public SynchronizationUserAccessListJob(string jobname, SPService service)
            : base(jobname, service, null, SPJobLockType.Job)
        {
            this.Title = jobname;
        }


        /// <summary>
        /// The timer job actually executes this method depending on its configuration, It will be done, every day.
        /// </summary>
        /// <param name="targetInstanceId"></param>
        public override void Execute(Guid targetInstanceId)
        {
share|improve this question
    
What scope of feature do you use? –  Alexander Mar 30 '12 at 14:26
    
farm scope!!!!! –  L.V. Sharepoint Architect Apr 2 '12 at 6:18
add comment

1 Answer

up vote 0 down vote accepted

If you use SPWeb or SPSite feature scope you can have a problem with security. Read this post or this post for more details.

I suggest you to use the SPFarm or SPWebApplication scoped feature. There is no problem with security.

share|improve this answer
    
its farm scoped. –  L.V. Sharepoint Architect Mar 30 '12 at 20:33
    
but then, whats the problem with my code? I wonder if the problem is with the object SPService. –  L.V. Sharepoint Architect Mar 30 '12 at 20:37
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.