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