title: "Operation is not valid due to the current state of the object" when deploying sharepoint event receiver
body: <p>I have a simple event receiver, when I create a constructor I got the error in deployment step, I double checked the event receiver scope in feature, Elements.xml file and my code, the weird thing is when I remove the constructor(where I use service locator to get an instance of my implementation class) it works fine.</p>
  
  <p>my code is something like this:</p>
  
  <pre><code>    private INotificationService iNotificationService;
      public CongeER()
      {
          SPSite currentSite = SPContext.Current.Site;
          IServiceLocator locator = SharePointServiceLocator.GetCurrent(currentSite);
  
          try
          {
              iNotificationService = locator.GetInstance&lt;INotificationService&gt;();
          }
          catch (System.Exception ex)
          {
              System.Console.WriteLine(ex.Message);
          }
      }
  
     public override void ItemAdded(SPItemEventProperties properties)
     {
         iNotificationService.NotifyByMail();
         base.ItemAdded(properties);
     }
  </code></pre>
  
  <p>here is my stackTrace:</p>
  
  <pre><code>  Feature Activation: Threw an exception, attempting to roll back.
    Exception: System.InvalidOperationException: 
    L'opération n'est pas valide en raison de l'état actuel de l'objet.     
    à Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionContentTypeAndEventReceiverBindings(SPFeaturePropertyCollection props, SPSite site, SPWeb web, Boolean fForce)     
    à Microsoft.SharePoint.Administration.SPElementDefinitionCollection.ProvisionElements(SPFeaturePropertyCollection props, SPWebApplication webapp, SPSite site, SPWeb web, Boolean fForce)     
    à Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boo...
  </code></pre>