简体   繁体   English

AutoMapper“锁定”网站并引发IndexOutOfRangeException

[英]AutoMapper “locks” the site and throws IndexOutOfRangeException

I am using AutoMapper on my web site. 我在我的网站上使用AutoMapper。 It works great, but about once every two weeks I get a yellow page (see stack trace below), and the only way to resolve this is to restart the site (recycle app pool). 效果很好,但是大约每两周我会看到一个黄页(请参阅下面的堆栈跟踪),解决此问题的唯一方法是重新启动网站(回收应用程序池)。 AutoMapper version: 2.0.9999 (as seen on file properties). AutoMapper版本:2.0.9999(如文件属性所示)。

Any ideas what this can be caused by? 任何想法这可能是由什么引起的? Is this a failure of the configuration step (which happens once)? 这是配置步骤的失败(发生一次)吗?

[IndexOutOfRangeException: Index was outside the bounds of the array.]
  System.Collections.Generic.Enumerator.MoveNext() +75
  System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +166
  AutoMapper.ConfigurationStore.FindExplicitlyDefinedTypeMap(Type sourceType, Type destinationType) +147
  AutoMapper.ConfigurationStore.FindTypeMap(Object source, Type sourceType, Type destinationType, String profileName) +169
  AutoMapper.ConfigurationStore.FindTypeMapFor(Object source, Type sourceType, Type destinationType) +279
  AutoMapper.MappingEngine.Map(Object source, Type sourceType, Type destinationType) +71
  AutoMapper.MappingEngine.Map(TSource source) +190
  AutoMapper.Mapper.Map(TSource source) +105
  WowReforge.ViewModels.ReforgeViewModel.LoadToonGear(IDictionary`2 gear, IDictionary`2 itemsRefInfo) +307
  ...

Looking at the System.Linq.Enumerable FirstOrDefault in ILSpy, there is call to IEnumerator.MoveNext, like it's indicated in the stacktrace that you provided. 查看ILSpy中的System.Linq.Enumerable FirstOrDefault,有对IEnumerator.MoveNext的调用,就像在您提供的stacktrace中指出的那样。 But it does not indicate what implementation of IEnumerator it is. 但这并不表示它是IEnumerator的实现。 From that it is hard to tell what can actually happen in MoveNext. 因此,很难说出MoveNext中可能发生的实际情况。

What are the objects involved in the mapping? 映射涉及哪些对象? What type of collections are you using? 您正在使用哪种类型的收藏集?

If you are using an implementation of IEnumerator of your own, could it be that you are doing something wrong when providing a value for Current or calculating the indexes wrong in your MoveNext method? 如果您使用自己的IEnumerator的实现,是否可能是在为Current提供值或在MoveNext方法中计算索引错误时做错了什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM