gpt4 book ai didi

sharepoint - 特征事件有 'null' 个对象

转载 作者:行者123 更新时间:2023-12-03 09:57:39 26 4
gpt4 key购买 nike

public class Feature1EventReceiver : SPFeatureReceiver
{

public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{

string sContextNull = (SPContext.Current == null) ? "Context is NULL" : "Context is OK";
string sFeatureNull = (properties.Feature == null) ? "Feature is NULL" : "Feature is OK";

// Some code here
...
...
{
}

该功能已成功安装(日志中没有错误)。我的问题是 sContextNull 总是返回 "Context is NULL"。而且 sFeatureNull 也总是返回 "Feature is NULL"。有没有办法获取 SPContext.Currentproperties.Feature 的非空值?

另一种方法 FeatureActivated 返回 Context is NULLFeature is OK。什么鬼?

最佳答案

SPContext.Current

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.current.aspx

获取 Microsoft SharePoint Foundation 中当前 HTTP 请求的上下文。

SPFeatureReceiver.FeatureInstalled 在功能安装到场时执行,这是通过来自 stsadm 或 powershell 的部署/安装命令完成的,然后通常会触发计时器作业来完成工作。此时没有HTTP请求,所以SPContext.Current返回null。

关于sharepoint - 特征事件有 'null' 个对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5603546/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com