2010-11-19 44 views
1

我有這樣一個類:如何爲SharePoint計時器作業設置我的Feature.xml?

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> 

我的組件稱爲SharePointSocialNetworking。我在這裏做錯了什麼?

我已經做了所有適當的設置,但是當我運行此命令:

stsadm -o installfeature -name SharePointSocialNetworking 

我得到的錯誤:

Object reference not set to an instance of an object. 

回答

0

你父母的特徵是不是一個網站,但農場,你不應該將其投射到SPSite

相關問題