【问题标题】:automapper works fine in debug mode but throws mappingexception in release modeautomapper 在调试模式下工作正常,但在发布模式下抛出映射异常
【发布时间】:2014-12-19 20:37:28
【问题描述】:

Automapper 是一个很好的工具。但我有一些问题。

在调试项目时它工作正常,所有映射操作都成功。但在发布模式下,它会抛出具有完全相同数据的映射异常。

可能是什么问题?

我的环境是 Win7 , 32 bit, VS 2010 。项目适用于 .net 4.0 配置文件。

 Mapper.CreateMap<V_Person_Details,Person>();
 Mapper.Map(curr_V_Person, cur_Person); /// exception throws here in just release mode , not in debug mode 
   ///Trying to map System.String to System.nullable .... Destination property  SSS_ID : exception of the Automapper.AutomapperMappingException was thrown.

 ....

【问题讨论】:

  • mapping exception 是关于什么的?
  • 试图将 System.string 映射到 System.nullable'1 ...但它在调试模式下使用相同的数据工作正常。
  • 对我来说,您似乎在调试和发布中绑定到不同的databases

标签: c# automapper


【解决方案1】:

在调试模式下运行 Mapper.AssertConfigurationIsValid() 方法以验证您没有任何仅在发布模式下显示的配置错误。

【讨论】:

  • 感谢所有回答。终于看到原因了。在 vprsdetails 表中,SSID 数据存储为 TEXT,而在 prs 表中,SSID 数据存储为 INTEGER。所以实际上它也应该在调试模式下抛出异常,但它不会给出任何异常。所以在调试模式下它不会抛出任何异常。但是在发布模式下,您可以很好地看到一切。所以检查错误细节作为检查配置验证是个好主意。
【解决方案2】:

我们有同样的问题。 对我们来说,问题是我们服务器上的另一个版本的 AutoMapper dll(发布)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 2013-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多