Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

share|improve this question
    
whats the error? how long are you waiting between step 3-4 and 4-5 and how many wsp's are you doing at any one time? –  ali Sharepoint Apr 30 '13 at 8:18
    
I've updated the question. Thanks for taking the time to look at it. –  Thomas Apr 30 '13 at 8:52
add comment

2 Answers 2

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

share|improve this answer
    
Thanks for the tip. I've tried resetting (Restart-Service) SPTimerV4, SPAdminV4 and SPUserCodeV4 (even though I don't have any sandboxed solutions) before doing an iisreset and still nothing. –  Thomas Apr 30 '13 at 9:13
    
Beware that it takes some time for Timer V¤ etc. to rebuild their cache though –  Robert Lindgren Apr 30 '13 at 9:14
    
Should I then wait for a few seconds after doing such a reset in order for it to update correctly? –  Thomas Apr 30 '13 at 9:15
    
Maybee, I too often have difficulties with feature receivers, especiallt for "empty" features with no elements or modules in them –  Robert Lindgren Apr 30 '13 at 9:15
    
Ok, thanks. I'll give it a try. –  Thomas Apr 30 '13 at 9:16
add comment
up vote 0 down vote accepted

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.