title: "Source array was not long enough" Error registering BsonClassMap conventions in mongodb with C# driver
body: <p>In the following code:</p>
  
  <pre><code>var myConventions = new ConventionProfile();
  myConventions.SetIgnoreExtraElementsConvention(new AlwaysIgnoreExtraElementsConvention());
  BsonClassMap.RegisterConventions(myConventions, (type) =&gt; true);
  </code></pre>
  
  <p>whenever it calls RegisterConventions, we are getting the following error, but it is very intermittent and random, and so it's very hard to troubleshoot.</p>
  
  <blockquote>
    <p>"Source array was not long enough. Check srcIndex and length, and the
    array's lower bounds."</p>
  </blockquote>
  
  <p>A few times we've purged our collections and that's fixed it, but the last few times, we purged and still had to then restart the windows service.  Then we could use our application and create records and collections to our hearts' content.  </p>
  
  <p>I'm thinking perhaps an array in one or more of our mapped class's array properties is getting initialized inconsistently, but I'm drawing a blank on next steps to take.  I could perhaps use a field initializer or initialize it in the constructor, but I don't want to start mucking with mongo api's mapping magic.  Also, we haven't seen this error in at least a week, so if I made some sort of fix and left it in there, I'll have no way of knowing if it actually fixed the problem or not.</p>
  
  <p>Please help!  Thanks!</p>