【问题标题】:AutoMapper non-static conversion from static - MapperConfiguration, CreateMapperAutoMapper 从静态的非静态转换 - MapperConfiguration, CreateMapper
【发布时间】:2017-03-21 17:14:04
【问题描述】:

我正在从 .NET Framework 4 上混合使用 v2 和 v4 AutoMapper 静态编码迁移到使用 .NET Framework 4.6.2 的版本 6.0.1。我在 Visual Studio 2015 下的转换开发中遇到了问题。

var dummy = new MapperConfiguration(cfg => cfg.CreateMap<DateTime,string>());

Visual Studio 告诉我 MapperConfiguration.MapperConfiguration(Action configure) (+1 重载) 构造函数“MapperConfiguration”有 0 个参数,但使用 1 个参数调用。

当我编写下一行代码时:

var dmy1 = dummy.CreateMapper();

Visual Studio 告诉我 IMapper MapperConfiguration.CreateMapper()(+1 重载)无法解析符号 CreateMapper。

这都是基本的非静态内容,我可以用另一双眼睛提醒我我所缺少的东西。我在想一旦我用第一行代码解决了问题,另一个问题就会消失。想法?

【问题讨论】:

  • 抱歉,我正在从静态代码方法转换为非静态代码方法
  • 我使用 .NET 4.6.2 框架创建了一个新的 WinForm 项目,并使用 NuGet 将 AutoMapper 添加到我的项目中。我上面提到的问题不存在。所以它一定是我的解决方案中的某些东西导致了这个问题。

标签: c# automapper non-static


【解决方案1】:

当我重新启动 Visual Studio 时问题就消失了。 VS 实例中一定有一些残留物导致了问题。

【讨论】:

    【解决方案2】:

    我在 Edmx 更新后遇到了同样的问题。 Visual Studio 重启后问题消失。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多