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:
- Uninstall all relevant WSPS (removing from the GAC)
- Restart: SPAdminV4, SPTimerV4, SPUserCodeV4 and IISReset
- Install all relevant WSPS including the one that should be the target for the event receiver.
- Restart: SPAdminV4, SPTimerV4, SPUserCodeV4 and IISReset
- 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)