Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为SharePoint计时器作业设置my Feature.xml?_Sharepoint_Sharepoint Timer Job - Fatal编程技术网

如何为SharePoint计时器作业设置my Feature.xml?

如何为SharePoint计时器作业设置my Feature.xml?,sharepoint,sharepoint-timer-job,Sharepoint,Sharepoint Timer Job,我有一门课是这样的: namespace SharePointSocialNetworking { public class FeatureToEnableJob : SPFeatureReceiver { public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.P

我有一门课是这样的:

namespace SharePointSocialNetworking
{   
    public class FeatureToEnableJob : SPFeatureReceiver
    {
      public override void FeatureActivated(SPFeatureReceiverProperties properties)
      {

        SPSite site = properties.Feature.Parent as SPSite;

        // Make sure the job isn't already registered.
        foreach (SPJobDefinition job in site.WebApplication.JobDefinitions)
        {
            if (job.Name == "SPFacebookJob")
                job.Delete();
        }

        // Install the job.
        Facebook fbJob = new Facebook();

        SPMinuteSchedule schedule = new SPMinuteSchedule();
        schedule.BeginSecond = 0;
        schedule.EndSecond = 59;
        schedule.Interval = 2;
        fbJob.Schedule = schedule;

        fbJob.Update();
      }
      ...
    }

}
这是我的功能XML:

<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" 
 Id="b9e40341-32ab-410a-a20f-282cf13fb54b" 
 ReceiverAssembly="SharePointSocialNetworking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6264b0911592ad29" 
 ReceiverClass="SharePointSocialNetworking.FeatureToEnableJob" 
 Scope="Farm" 
 Title="SharePoint Social Networking Job">
</Feature>
我得到一个错误:

Object reference not set to an instance of an object.

您的要素父项不是站点而是场,您不应该将其强制转换到SPSite

Object reference not set to an instance of an object.