通过命令行停用功能不会触发 SPFeature 事件接收器
我正在通过 stsadm 工具停用一项功能。我有一个为此操作启用的事件接收器。如果我从站点手动停用该功能,该事件将被触发,但在运行 stsadm 命令时不会被触发。
请帮忙...
这是代码 Sylvain:
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
Logging.Log(_componentName, "The document library feature has deactivated successfully.");
}
I am deactivating a feature through stsadm tool. I have an event reciever enabled for this action. If i deactivate the feature manually from the site the event is getting triggered but not when running stsadm command.
Please help...
Here is the code Sylvain:
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
Logging.Log(_componentName, "The document library feature has deactivated successfully.");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在事件接收器的代码中,您是否使用 SPContext.Current (或其他 Web-Context 对象)...?
如果是这样,您的代码可以在网站上运行,但不能脱离 Web 上下文(如 stsadm 或命令行),因为 SPContext.Current 为 null。
检查这一点,但很可能这就是问题所在。
In the code of your event receiver, do you use SPContext.Current (or other Web-Context objects)... ?
If so, your code works on the site, but not out of web-context (like stsadm or command line) because SPContext.Current is null.
Check this point, but there's a good probability that's the problem.
正如 Sylvain Reverdy 指出的那样,你的特色接球手失败的可能性比没有被叫到的可能性更大。查看 SharePoint 日志 - 所有功能激活/停用/安装步骤都在那里跟踪(位置 - c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS,请参阅 SharePoint/MOSS 的默认日志位置在哪里?)。
确保您没有使用 StsAdm 命令的“-force”选项 - 它使 stsadm 忽略停用期间的故障。
As Sylvain Reverdy pointing out it is more likley your feature receiver to fail than not beeing called. Check out SharePoint logs - all feature activation/deactivation/installation steps are traced there (Location - c:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS, see Where is the default log location for SharePoint/MOSS?).
Make sure you are not using "-force" option of StsAdm command - it makes stsadm to ignore failures during deactivation.