title: AutoMapper index out of bounds exception in MappingEngine.cs
body: <p>Currently we are running AutoMapper 1.0.1.156 in production on a WCF webservice and after about a week or so we will start to get the following error (note this was also happening in 0.4.0.126 but we couldn't get a stack trace because we only had the .dll from codeplex and no .pdb):</p>
  
  <blockquote>
    <p>Trying to map DataAccess.Call to DataTypes.Call.<br>
    Using mapping configuration for DataAccess.Call to DataTypes.Call<br>
    Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.<br>
    at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context) in C:\Work\AutoMapper\src\AutoMapper\MappingEngine.cs:line 154<br>
    at AutoMapper.MappingEngine.Map(Object source, Type sourceType, Type destinationType) in C:\Work\AutoMapper\src\AutoMapper\MappingEngine.cs:line 104<br>
    at AutoMapper.MappingEngine.Map[TSource,TDestination](TSource source) in C:\Work\AutoMapper\src\AutoMapper\MappingEngine.cs:line 34<br>
    at AutoMapper.Mapper.Map[TSource,TDestination](TSource source) in C:\Work\AutoMapper\src\AutoMapper\Mapper.cs:line 21  </p>
  </blockquote>
  
  <p>Here is the mapping configuration for the Map being executed when the error happens:</p>
  
  <pre><code>Mapper.CreateMap&lt;DataAccess.Call, DataTypes.Call&gt;()
      .ForMember(dest =&gt; dest.CallTypeId, opt =&gt; opt.MapFrom(src =&gt; src.CallType))
      .ForMember(dest =&gt; dest.CallType, opt =&gt; opt.MapFrom(src =&gt; (DataTypes.CallType)src.CallType));
  </code></pre>
  
  <p>The code runs find for about a week or so with no errors. Once we start getting errors, if we recycle the application pool for the WCF webservice, the error goes away.</p>
  
  <p>I have double checked, triple checked, and rechecked that src.CallType can not possibly contain any values which are not in the enum DataTypes.CallType.</p>
  
  <p>The class/enum definitions are at <a href="http://pastebin.com/2pF0gFZ2" rel="nofollow noreferrer">http://pastebin.com/2pF0gFZ2</a></p>
  
  <p>Searched all over and couldn't find anybody else having this issue.</p>