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 have a C# event receiver that utilizes the ItemUpdating event. The project was originally created as a Sandboxed solution and worked fine, however, due to limitations I've decided to switch over to a farm solution. When doing this, I found out that I had to set the scope as Site or Web (as Farm and WebApp caused the packaging process to bomb out). This is fine, but when I deploy as a Site scope and activate the solution at a site collection, the event handler is not firing like it was when it was sandboxed.

Couple questions:

  1. can event handlers be deployed as farm solutions at the Site scope?
  2. how can I test to see if the event handler is being hit at all? I have a multi-server farm, so I am using PS to deploy the solution in the first place, so debugging doesn't appear to be an option
share|improve this question
    
So, I decided to create a new project from scratch. After doing so, I set the Assembly Deployment Target to WebApplication. I then built and packaged the solution. I then ran PowerShell to deploy the solution (which is something I do often for custom web parts). Now, I am getting the following error when activating the feature: Operation is not valid due to the current state of the object. This is different than the first issue. Before, I could activate the feature just fine, but the code was not firing. Now, I cannot activate the feature. Thoughts? –  Josh Sep 24 '12 at 23:49
    
Such case happened with me, i uninstalled the dll from the GAC then i deployed again –  user18090 Jul 6 '13 at 13:24

2 Answers 2

We got the event receiver to work. The problem is that the deployment of the WSP is not copying the DLL to the GAC. We are having to do this manually. Any reason for that? Is this a Visual Studio 2010 configuration option? Thanks.

share|improve this answer
    
We had our project set to WebApplication instead of GlobalAssemblyCache. Seeing if we can set the DLL path in the feature.xml... –  Josh Sep 25 '12 at 22:49
    
Setting the project ot WebApplication deploys the assembly to the bin folder of the WebApp. Setting it to GlobalAssemblyCache will put it there, and your 4 part reference in your Feature manifest should pick it up. –  James Love Feb 2 '13 at 11:52
    
How were you deploying the solution? If you do it via Powershell there's a flag you can add called -GACDeployment; in fact, if you have to publish to the GAC and you don't turn that flag on, it tends to throw an error. –  NotVonKaiser Jun 11 '13 at 14:35

For debugging purposes you could try using SPLog.
Then you can view the ULS log.

SPLog.GetInstance("MyReceiver").Info("Bump!");

When it comes to deploying to farm remember to activate the feature on every SPSite :)

share|improve this answer

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.