0

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)

2
  • 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? Commented Apr 30, 2013 at 8:18
  • I've updated the question. Thanks for taking the time to look at it. Commented Apr 30, 2013 at 8:52

2 Answers 2

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

4
  • 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. Commented Apr 30, 2013 at 9:13
  • Beware that it takes some time for Timer V¤ etc. to rebuild their cache though Commented Apr 30, 2013 at 9:14
  • Should I then wait for a few seconds after doing such a reset in order for it to update correctly? Commented Apr 30, 2013 at 9:15
  • Maybee, I too often have difficulties with feature receivers, especiallt for "empty" features with no elements or modules in them Commented Apr 30, 2013 at 9:15
1

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/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.