Question

I'm activating a feature using PowerShell and every "once in a while" it fails with the error "Failed to load receiver assembly". It seems to be complaining because some service or application is unable to find the dll in the GAC however I've checked every time and the dll is always correctly deployed to the GAC. My powershell script runs like this:

  1. Uninstall all relevant WSPS (removing from the GAC)
  2. Restart: SPAdminV4, SPTimerV4, SPUserCodeV4 and IISReset
  3. Install all relevant WSPS including the one that should be the target for the event receiver.
  4. Restart: SPAdminV4, SPTimerV4, SPUserCodeV4 and IISReset
  5. Actiavte the feature (web application scoped)

I've tried pausing the script between step 3 and 4 and between step 4 and 5 to verify that the DLL is present and it always is. I've checked that the feature xml ReceiverAssembly is correct, but I don't think this is the issue as it works most of the time.

I'm able to run the script several times successfully and suddenly it will fail. Is there some service I need to recycle in addition to an iisreset?

Edit Additional details:

  • There are 10 wsps, one of which contains a web application scoped feature.
  • I do not wait for any amount of time after the reset as I thought the recycling was complete once iisreset returned.
  • The error occurs when sharepoint tries to call the custom FeatureActivated event receiver in one of the wsps.
  • Partial stack trace (abbreviated): System.ArgumentException: Failed to load receiver assembly [full receiver assembly signature] or one of its dependencies. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly [full receiver assembly signature]

edit: Added service recycle steps.

(I'm unable to post exact code because the system is on a restricted network)

Was it helpful?

Solution 2

I solved the problem. It seems there is no need for me to reset either IIS or SPAdminV4 during the deployment. Removing all references to this from my PowerShell script solved the issue.

I should also note that waiting 5 seconds after resetting SPAdminV4 before activating the feature also avoided the error.

Ref: http://blog.falchionconsulting.com/index.php/2011/04/deploying-sharepoint-2010-solution-package-using-powershell-revisited/

OTHER TIPS

Often this is due to the SPTimerV4 holding a cached reference to your solution .dll:s

try do

net stop SPTimerV4
net start SPTimerV4

in PowerShell or cmd when you have retracted your .wsp before reinstalling them

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top