title: SharePoint: Error on unregistering an EventReceiver form a ContentType
body: <p>I've got some problems unregistering some eventreceivers form a contenttype. The contenttype and the receivers were deployed and registered by myself so I don't try to remove any MOSS built-in or internal eventreceivers. </p>
  
  <p>I trying to archive this with the following code snippet:</p>
  
  <pre><code>using (SPSite site = new SPSite("http://wssdev06/"))
          {
              using (SPWeb web = site.RootWeb)
              {
                  // web.AllowUnsafeUpdates = true;
  
                  SPContentType type = web.AvailableContentTypes[&lt;ContentTypeName&gt;];
  
                  while (type.EventReceivers.Count &gt; 0)
                  {
                      type.EventReceivers[0].Delete();                        
                  }
  
                  type.Update();
  
                  // web.AllowUnsafeUpdates = false;
              }
          }
  </code></pre>
  
  <p>Unfortunately the command "type.Update()" throws an exception telling me that the collection cannot be modified. As you can see in the code I've already tried different things to solve this problem, as allowing unsafe updates or running this code with elevated privileges. But I always get the same exception.  </p>
  
  <p>So what am I doing wrong?</p>