无法通过 PowerShell 使用功能接收器启用功能

发布于 2024-09-24 02:59:54 字数 532 浏览 0 评论 0原文

我遇到了一个问题,我可以通过站点设置启用 UI 功能,并且一切都按预期工作,但是如果我尝试通过 Sharepoint powershell 启用该功能(我们正在将其作为脚本部署的一部分),我得到下列:

Enable-SPFeature:创建失败 来自程序集“xxxxx”的接收者对象, 版本=1.0.0.0,文化=中立, 公钥令牌 = 967e6960f5af91e6 ", 类“xxxxx.EventReceiver”用于 功能“xxxxx.Public.Search”(ID: 026d7c45-a359-4550-822d-1a6c35e58e0 d).: System.ArgumentNullException: 值不能为空。参数名称: 类型

有谁知道为什么会发生这种情况,或者我应该检查一些事情 功能定义绝对是正确的(因为通过 UI 部署它可以按预期工作,而且我还仔细检查了 PublicKeyToken 是否正确等),并且重新启动服务和 iisreset 也不能​​让我使用 Enable-SPFeature。

I've got a problem where I can enable a feature the UI and everything works as expected through site settings, but if I try and enable the feature via the Sharepoint powershell (which we are doing as part of a scripted deployment), I get the following:

Enable-SPFeature : Failed to create
receiver object from assembly "xxxxx,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=967e6960f5af91e6 ",
class "xxxxx.EventReceiver" for
feature "xxxxx.Public.Search" (ID:
026d7c45-a359-4550-822d-1a6c35e58e0
d).: System.ArgumentNullException:
Value cannot be null. Parameter name:
type

Does anyone know why this would occur, or some things I should check? The feature definition is definitely correct (since deploying it through the UI works as expected, and I've also double checked the PublicKeyToken is correct etc etc), and restarting the services and iisreset doesn't enable me to use Enable-SPFeature either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

熟人话多 2024-10-01 02:59:54

我有同样的问题。奇怪的是,当您打开一个新的 SP2010 powershell 窗口并重新发出相同的命令时,发现程序集没有任何问题。看:
http://khurramdotnet.blogspot.com/2011/01/enable-spfeature-command-投掷.html

I have the same issue. The curious thing is when you open up a new SP2010 powershell window and reissue the same command the assembly is found without any problems. See:
http://khurramdotnet.blogspot.com/2011/01/enable-spfeature-command-throwing.html

猫瑾少女 2024-10-01 02:59:54

试试这个:转到控制面板,单击“程序”,单击“程序和功能”,选择“Microsoft SharePoint Server 2010”(或您已安装的任何内容),单击“更改”,选择“修复”,然后单击“继续”。这对我有帮助。

Try this: go to the Control Panel, click on "Programs", click on "Programs and Features", select "Microsoft SharePoint Server 2010" (or whatever you have installed), click "Change", select "Repair" and click "Continue". This is what helped me.

蒲公英的约定 2024-10-01 02:59:54

试试这个:http://geoffwebbercross.blogspot。 ca/2011/06/failed-to-create-receiver-object-from.html
它对我有用,我不需要改变我的代码/解决方案中的一针一线

Try this: http://geoffwebbercross.blogspot.ca/2011/06/failed-to-create-receiver-object-from.html
It worked for me, I did not have to change a stitch in my code / solution

枯寂 2024-10-01 02:59:54

我昨天遇到了这个,结果发现功能名称和功能接收器名称不匹配。为了解决这个问题,我将 FeatureActivated 代码复制到记事本(整个代码块)或您编码的任何事件中。

  1. 复制您的整个事件代码
    已经写了即
    FeatureActivated 方法(包括
    签名)
  2. 删除EventReceiver
    从你的项目中。
  3. 添加新事件
    收到您的项目(您可以
    仔细检查名称是否有更改)
  4. 将事件代码粘贴回
    事件接收器。

我使用以下代码使用powershell进行部署

    if(($Solution -ne $null) -and ($Solution.ContainsWebApplicationResource))
    {
        if ($FeatureScope -eq "Web")
        {
            Install-SPSolution $SolutionName -url $siteUrl -GACDeployment -Confirm:$false
        }
        else
        {
            Install-SPSolution $SolutionName -AllWebApplications -GACDeployment -Confirm:$false
        }
    }
    else
    {
        Install-SPSolution $SolutionName -GACDeployment -Confirm:$false
    }
    while($Solution.Deployed-eq$false)
    {
        Start-Sleep 2
        Write-Host "." -NoNewline
    }

I had this yesterday, turns out the feature name and the feature receiver name werent matching. To resolve it I copied the FeatureActivated code into notepad (entire code block) or whichever events it is you have coded.

  1. Copy the entire event code that you
    have written I.e. the
    FeatureActivated method (including
    signature)
  2. Remove the EventReceiver
    from your project.
  3. Add a new event
    received to your project (you can
    double check the name for changes)
  4. Paste the Event code back into the
    event receiver.

I use the following code to deploy using powershell

    if(($Solution -ne $null) -and ($Solution.ContainsWebApplicationResource))
    {
        if ($FeatureScope -eq "Web")
        {
            Install-SPSolution $SolutionName -url $siteUrl -GACDeployment -Confirm:$false
        }
        else
        {
            Install-SPSolution $SolutionName -AllWebApplications -GACDeployment -Confirm:$false
        }
    }
    else
    {
        Install-SPSolution $SolutionName -GACDeployment -Confirm:$false
    }
    while($Solution.Deployed-eq$false)
    {
        Start-Sleep 2
        Write-Host "." -NoNewline
    }
⒈起吃苦の倖褔 2024-10-01 02:59:54

不要使用“普通”PowerShell,而应使用 SharePoint 2010 Management Shell。

Don't use the "normal" PowerShell, use the SharePoint 2010 Management Shell instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文