新服务器上的AutoMapper数据类型转换异常

发布于 2025-02-10 04:29:55 字数 1465 浏览 3 评论 0原文

我有一个ASP REST API,在VS中也可以在我们的旧服务器和测试系统上运行良好。但是,当我尝试访问API(不是全部)时,我会得到日期映射异常。 ,旧的服务器和新服务器的设置以及数据库以及仅数据库的设置相等

对我来说 在任何其他系统上重现错误。

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
TTestingConfiguration -> TestingConfigurationDTO
Entities.TTestingConfiguration -> Models.TestingConfigurationDTO

Type Map configuration:
TTestingConfiguration -> TestingConfigurationDTO
Entities.TTestingConfiguration -> Models.TestingConfigurationDTO

Destination Member:
HexCreationDate

 ---> System.FormatException: 23.04.2020 13:27 is not a valid value for DateTime.
 ---> System.FormatException: String '23.04.2020 13:27' was not recognized as a valid DateTime.
   at System.DateTime.Parse(String s, IFormatProvider provider)
   at System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   --- End of inner exception stack trace ---
   at System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
   at AutoMapper.Mappers.TypeConverterMapper.Map[TSource,TDestination](TSource source)
   at lambda_method2000(Closure , Object , TestingConfigurationDTO , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method2000(Closure , Object , TestingConfigurationDTO , ResolutionContext )

I have a asp rest api which runs fine on our old server and test systems as well in VS. But when i try to access apis (not all) i get an Date Time mapping exception. For me the old server and the new server are setup equal as well the database and the data only the old server is windows server 2012 and the new is window server 2022.

So I don't even know where to start looking because I can not reproduce the error on any other system.

AutoMapper.AutoMapperMappingException: Error mapping types.

Mapping types:
TTestingConfiguration -> TestingConfigurationDTO
Entities.TTestingConfiguration -> Models.TestingConfigurationDTO

Type Map configuration:
TTestingConfiguration -> TestingConfigurationDTO
Entities.TTestingConfiguration -> Models.TestingConfigurationDTO

Destination Member:
HexCreationDate

 ---> System.FormatException: 23.04.2020 13:27 is not a valid value for DateTime.
 ---> System.FormatException: String '23.04.2020 13:27' was not recognized as a valid DateTime.
   at System.DateTime.Parse(String s, IFormatProvider provider)
   at System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   --- End of inner exception stack trace ---
   at System.ComponentModel.DateTimeConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
   at AutoMapper.Mappers.TypeConverterMapper.Map[TSource,TDestination](TSource source)
   at lambda_method2000(Closure , Object , TestingConfigurationDTO , ResolutionContext )
   --- End of inner exception stack trace ---
   at lambda_method2000(Closure , Object , TestingConfigurationDTO , ResolutionContext )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文