0

I am trying to make a simple timer job which does some task.

However its throwing an exception object reference not set to reference of an object as the input parameter SPFeatureReceiverProperties is coming as null.

On further debugging,it throws file not found exception however ,I rechecked my Urls they are alright.

Currently I am deploying my WSP by using central Admin.

My feature.xml looks like this

<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="15002E0E-C0D8-4BFF-B77F-BF285CD7313E"
ReceiverAssembly="ExceptionalAccessSendMail, Version=1.0.0.0, Culture=neutral,      
PublicKeyToken=ed2d27ff379c4b72"
ReceiverClass="ExceptionalAccessSendMail.Features.Feature1.Feature1EventReceiver"
Scope="WebApplication"
Title="SendAccessExpirationNotification">
</Feature>

here is the EventReciever feature Activated Function

    [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true)]
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {

        if (properties == null)
            throw new ArgumentException("properties");
        try
        {
            if( (properties!=null) && (properties.Feature!=null) &&    
     (properties.Feature.Parent is SPWebApplication))
            {
                SPWebApplication spWebApplication = properties.Feature.Parent as   
        SPWebApplication;

                if (spWebApplication == null)
                    throw new SPException("null object SPWebApplication in class 
          JobInstallerReciever");

                foreach (SPJobDefinition jobDefinition in  
    spWebApplication.JobDefinitions)
                    if (jobDefinition.Name == Globals.JOBNAME) jobDefinition.Delete();

                ExceptionalRevokeNotificationJob exceptionalRevokeNotificationJob =
                    new ExceptionalRevokeNotificationJob(spWebApplication);


                SPMinuteSchedule schedule = new SPMinuteSchedule();
                schedule.BeginSecond = 0;
                schedule.EndSecond = 59;
                schedule.Interval = 1;

                exceptionalRevokeNotificationJob.Schedule = schedule;
                exceptionalRevokeNotificationJob.Update();
            }
        }
        catch (Exception ex)
        {
            Debug.Write(ex.Message);
        }


    }

The execute looks like below

public override void Execute(Guid targetInstanceId)
    {
        try
        {

            lock (this)
            {

                if ((this.WebApplication != null) && (this.WebApplication.Sites.Count 
    > 0) && (this.WebApplication.Sites["sites/development/ExceptionalAccess"] != null))
                {
                    SPSite spSite = this.WebApplication.Sites["sites/development
            /ExceptionalAccess"];
                    string s = string.Empty;

                    using (SPWeb web = spSite.OpenWeb())
                    {
                        s = web.Url;
                    }

                }
            }
        }

        catch (Exception ex)
        {
            Debug.Write(ex.Message);
        }

    }

Any Ideas and help will be greatly appreciated.

thanks in Advance

1
  • please add some code to this post to let us help solve this problem Jul 16, 2011 at 12:23

1 Answer 1

1

Since you scoped the feature on webapplication level, you have to get the properties like:

SPWebApplication webApp = properties.Feature.Parent as SPWebApplication

Are you using this? Returns webApp null?

4
  • I am getting properties as null .....
    – Devo
    Jul 18, 2011 at 4:21
  • Could you please update your question with the code you are using? Jul 18, 2011 at 8:33
  • Hi I have updated my question with snippets
    – Devo
    Jul 18, 2011 at 11:44
  • I tested your code and I can't get the SPFeatureReceiverProperties null. Is there any more info I need to know about? Jul 19, 2011 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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