写了一个timer job, 通过F5调试时出现以下错误,各位大侠,看有没有可以帮忙解决下的?

hansier 2011-10-14 03:16:22
写了一个timer job, 通过F5调试时出现以下错误, 各位大侠,看有没有可以帮忙解决下的?


Error1 Error occurred in deployment step 'Add Solution': Failed to create receiver object from assembly "netsourcecodeTimerJob, Version=1.0.0.0, Culture=neutral, PublicKeyToken=15c79ab43b7ee851", class "$SharePoint.Type.c48f6b8a-6f1d-4f1e-996b-ea0a6baae3e7.FullName$" for feature "netsourcecodeTimerJob_netsourcecodeFeature" (ID: 07135222-3239-49f2-a3d1-71e6664042c8).: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()


...全文
152 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Justin-Liu 2011-10-21
  • 打赏
  • 举报
回复
你激活feature没?
重启Timer服务
对 附加到OWSTIMER.EXE进程,我上面儿说错了
hansier 2011-10-20
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 foxdave 的回复:]
显示所有用户所有进程 窗体下面有选项
[/Quote]

我在debug/ Attach to process 添加 OWSTIMER.EXE 进程来,
调试步骤如下: 通过进入 sharepoint Administration -> Monitoring -> Review Job Definitions 在这里面没有找到我的job 的名字呢, 这是什么原因呢?
(这里应该有我job 的名字的吧,然后我选择我的job name, click Run Now 的)
hansier 2011-10-18
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 foxdave 的回复:]

肿么分析啊 看着头疼。。。
C# code
SPSite Site = properties.Feature.Parent as SPSite;

这句?
你挂W3WP进程调一下 一下就知道了
[/Quote]

在 debug/ Attach to process 里面没有看到有W3WP 这个进程呢,
Justin-Liu 2011-10-18
  • 打赏
  • 举报
回复
显示所有用户所有进程 窗体下面有选项
hansier 2011-10-18
  • 打赏
  • 举报
回复
有没有高手帮忙看看呢,,
a-zhwang 2011-10-17
  • 打赏
  • 举报
回复
你的Timer 类有问题,看看构造函数是否实现了。
Justin-Liu 2011-10-17
  • 打赏
  • 举报
回复
肿么分析啊 看着头疼。。。
SPSite Site = properties.Feature.Parent as SPSite;

这句?
你挂W3WP进程调一下 一下就知道了
hansier 2011-10-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 foxdave 的回复:]
空引用错误
dll写得不对
[/Quote]

hi FoxDave, 以下是我贴出的代码,其实这也是按照网上列子来写的:(麻烦您能抽时间帮我分析下,
看看我到底出错在哪里了,谢谢)

1. CopyPageTimerJob.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Administration;


namespace netsourcecodeTimerJob
{

class CopyPageTimerJob :SPJobDefinition
{
public const string jobName = "CopyPageTimerJob";

public CopyPageTimerJob()
: base()
{

}

public CopyPageTimerJob(string jobName, SPService service, SPServer server, SPJobLockType targetType)

: base(jobName, service, server, targetType)
{

}

public CopyPageTimerJob(string jobName, SPWebApplication webApplication)

: base(jobName, webApplication, null, SPJobLockType.ContentDatabase)
{

this.Title = "Copy Page Timer Job";

}


public override void Execute(Guid contentDbId)
{
SPWebApplication webApplication = this.Parent as SPWebApplication;
// SPContentDatabase contentDb = webApplication.ContentDatabases[contentDbId];
SPList taskList = webApplication.Sites[0].RootWeb.Lists["test_SyncSource"];
SPListItem newTask = taskList.Items.Add();
newTask["Title2"] = DateTime.Now.ToString();
newTask.Update();

}
}
}



2. netsourcecodeFeature.EventReceiver.cs:

using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;



namespace netsourcecodeTimerJob.Features.netsourcecodeFeature
{
/// <summary>
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be modified.
/// </remarks>

//Guid("c48f6b8a-6f1d-4f1e-996b-ea0a6baae3e7")]
[Guid("59f008ab-310a-4f2b-b666-bdf278196d63")]

public class netsourcecodeFeatureEventReceiver : SPFeatureReceiver
{

private const string netsourcecodeTimerJobNAME = "netsourcecodeTimerJob";

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
///base.FeatureInstalled(properties);
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
//base.FeatureUninstalling(properties);
}

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{

SPSite Site = properties.Feature.Parent as SPSite;

// make sure the job isn't already registered

foreach (SPJobDefinition jJobDefinition in Site.WebApplication.JobDefinitions)
{

if (jJobDefinition.Name == netsourcecodeTimerJobNAME)
jJobDefinition.Delete();

}


CopyPageTimerJob cCopyTimer = new CopyPageTimerJob(netsourcecodeTimerJobNAME, Site.WebApplication);








SPMinuteSchedule sMinSchedule = new SPMinuteSchedule();
sMinSchedule.BeginSecond = 0;
sMinSchedule.EndSecond = 59;
sMinSchedule.Interval = 1;
cCopyTimer.Schedule = sMinSchedule;
cCopyTimer.Update();
//sDailySchedule.Interval = 5;


}

// Uncomment the method below to handle the event raised before a feature is deactivated.

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{

SPSite site = properties.Feature.Parent as SPSite;

// delete the job

foreach (SPJobDefinition jJobDefinition in site.WebApplication.JobDefinitions)
{

if (jJobDefinition.Name == netsourcecodeTimerJobNAME)
jJobDefinition.Delete();

}

}

}


}


麻烦给位大侠能指点指点下。 thanks in advance...!

Justin-Liu 2011-10-14
  • 打赏
  • 举报
回复
空引用错误
dll写得不对

3,245

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨 - LinyuLoveTJ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧