Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:34+00:00 2026-05-25T20:37:34+00:00

I created a custom timer job and implemented it through a feature event in

  • 0

I created a custom timer job and implemented it through a feature event in sharepoint.

when i tried to activate it, its showing this particular error:

Object reference not set to an instance of an object.   at TimerJobExample.MyFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties) in C:\Documents and Settings\admin-shuklag.INFRADEV\My Documents\Visual Studio 2008\Projects\TimerJobExample\TimerJobExample\MyFeatureReceiver.cs:line 22 
   at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) 
   at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) 
   at Microsoft.SharePoint.SPFeatureCollection.AddInternal(Guid featureId, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly) 
   at Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId) 
   at Microsoft.SharePoint.WebControls.FeatureActivator.BtnActivateFeature_Click(Object objSender, EventArgs evtargs) 
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e) 
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) 
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) 
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) 
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) 
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

The error line is highlighted below

public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {

        SPSite site = properties.Feature.Parent as SPSite;

        // make sure the job isn't already registered


//error line
      **foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)**

        {

            if (job.Name == List_JOB_NAME)

                job.Delete();

        }



        SampleTimer listLoggerJob = new SampleTimer(List_JOB_NAME, site.WebApplication);

        SPMinuteSchedule schedule = new SPMinuteSchedule();

        schedule.BeginSecond = 0;

        schedule.EndSecond = 59;

        schedule.Interval = 5;

        listLoggerJob.Schedule = schedule;

        listLoggerJob.Update();

    }

what could be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:37:34+00:00Added an answer on May 25, 2026 at 8:37 pm

    The problem was with the scope of the feature. It was set to Web, and for a feature to be activated at this level, u need an admin account or an account with elevated privileges.

    You can either add the application pool id to farm admin accounts or
    run the code with elevated rights.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a simple custom timer job for Sharepoint by using the template i
I created a custom timer job and deployed it into my development farm (MOSS
I created a custom timer component, which basically renders a circle sector, with a
It's not the first time I've created a Custom Event in C#. It boggles
I have created a custom style for my WPF datagrid by overriding its control
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I created a custom autocomplete control, when the user press a key it queries
I created a custom button component that accepts an array as a property. I
i created a custom menu called top-navigation. Now I'd like to style it with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.