title: Reproducing the 'non-concurrent collections must have exclusive access' exception
body: <p>I have the following code described in <a href="https://dotnetfiddle.net/GknA5Q" rel="nofollow noreferrer">https://dotnetfiddle.net/GknA5Q</a> from a production application. The <code>dictionary</code> is used as a <strong>cache</strong> to keep the properties of an object. The <strong>REST API</strong> where this <code>dictionary</code> is used has hundreds of object types, so the cache gets larger when the API finds more object types. The properties from the object is retrieved via <strong>reflection</strong> as you see in the code. The <code>dictionary</code> gets populated when the API is started and hundreds of requests reach the API. Each request will have a object type whose properties are getting cached.</p>
  <p>Although the REST API works, the code generates the following error now when the API starts in IIS. The line number that generates the error is 23 where <code>TryGetValue</code> is being called.</p>
  <blockquote>
  <p>Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.</p>
  </blockquote>
  <p>I'm trying to reproduce the same error in a test application, so some solution can be applied. I don't want to remove the <code>dictionary</code> which will add time for processing every model in every request that reaches the API. If this <code>dictionary</code> cache is available, the properties can be retrieved from the cache instead of parsing through reflection.</p>
  <p>How can I reproduce the above error?</p>