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 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

share|improve this question
    
please add some code to this post to let us help solve this problem –  Anders Rask Jul 16 '11 at 12:23

1 Answer 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?

share|improve this answer
    
I am getting properties as null ..... –  Devo Jul 18 '11 at 4:21
    
Could you please update your question with the code you are using? –  Anita Boerboom Jul 18 '11 at 8:33
    
Hi I have updated my question with snippets –  Devo Jul 18 '11 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? –  Anita Boerboom Jul 19 '11 at 11:05

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.