title: Why does GetGenericTypeDefinition fail?
body: <p>I have a piece of code which needs to check an entity when being saved by my Repository. I have an NHibernate interceptor on the save to check this but when I call the <code>GetGenericTypeDefinition</code> function the code fails with the error:</p>
  
  <blockquote>
    <p>[InvalidOperationException: Operation is not valid due to the current state of the object.]
       System.RuntimeType.GetGenericTypeDefinition() +7525641</p>
  </blockquote>
  
  <p>Code is this:</p>
  
  <pre><code>protected override object PerformSaveOrUpdate(SaveOrUpdateEvent evt)
  {
      if (evt.Entity.GetType().GetGenericTypeDefinition() == typeof(IChild&lt;&gt;))
      {
          var parent = (evt.Entity as IChild&lt;Entity&gt;).Parent;
          if (parent != null)
          {
              parent.UpdateCacheCounters();
              evt.Session.Save(parent);
          }
      }
  }
  </code></pre>
  
  <p>Any help would be much appreciated.</p>