Unable to enable function with function receiver via PowerShell

I had a problem where I can enable the user interface function and everything works as expected using the site settings, but if I try to enable this function through powershell Sharepoint (which we do as part of the deployment script), I get the following:

Enable-SPFeature: failed to create a receiver object from the assembly "xxxxx, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 967e6960f5af91e6", class "xxxxx.EventReceiver" for the function "xxxxx.Public.Search" (ID: 026d7c45- a359-4550-822d-1a6c35e58e0 d) .: System.ArgumentNullException: The value cannot be null. Parameter Name: Type

Does anyone know why this happened, or some things I should check? The definition of the function is definitely correct (since deploying it through the user interface works as expected, and I also double-checked that PublicKeyToken is right, etc. Etc.), and restarting the services and iisreset prevent me from using Enable-SPFeature.

+5
source share
5 answers

I have the same problem. Curiously, when you open a new PowerShell SP2010 window and reissue the same command that the assembly was found without any problems. See: http://khurramdotnet.blogspot.com/2011/01/enable-spfeature-command-throwing.html

+8
source

: , "", " ", "Microsoft SharePoint Server 2010" ( , ), "", "", "". .

+1

, werent. , FeatureActivated ( ) , .

  • , I.e. FeatureActivated ( )
  • Remove EventReceiver from your project.
  • Add a new event received in your project (you can double check the name for changes)
  • Paste the event code back into the event receiver.

I am using 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
    }
0
source

Do not use “normal” PowerShell, use the SharePoint 2010 Management Shell instead.

0
source

All Articles