1

我有一个 WPF 4.5 Prism 项目,在我添加 Automapper 3.0 之前它工作正常。当我将 Automapper 添加到我的 DAL 以便从实体框架对象转换为 DTO 时,应用程序在运行时失败,似乎是在创建 shell 之后立即失败。我在某处读到 Automapper 在某些情况下没有完全部署,因此我还在 Shell 项目中添加了对 Automapper 和 Automapper.Net4 的引用,以确保所有内容都已部署。

这是我收到的错误消息:

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.

这是我添加的导致异常的代码:

namespace DAL
{
[PartCreationPolicy(CreationPolicy.NonShared)]
[Export(typeof(ICampaignActionDataAccess))]
public class CampaignActionDataAccess : ICampaignActionDataAccess
{
    public CampaignActionDataAccess()
    {
        //if (Mapper.FindTypeMapFor<CampaignAction, CampaignActionDTO>() == null)
        //    Mapper.CreateMap<CampaignAction, CampaignActionDTO>();
        //if (Mapper.FindTypeMapFor<CampaignActionGroup, CampaignActionGroupDTO>() == null)
        //    Mapper.CreateMap<CampaignActionGroup, CampaignActionGroupDTO>();
        //if (Mapper.FindTypeMapFor<CampaignActionDescriptor, CampaignActionDescriptorDTO>() == null)
        //    Mapper.CreateMap<CampaignActionDescriptor, CampaignActionDescriptorDTO>();
    }

    public IEnumerable<CampaignActionDTO> GetAllActiveCampaignActions()
    {
        //using (var db = new CampaignActionEntities())
        //{
        //    var actions = (from ca in db.CampaignActions.Include(d => d.CampaignActionDescriptors)
        //                   where ca.IsValid == true
        //                   select ca).ToList();
        //    return Mapper.Map<IEnumerable<CampaignActionDTO>>(actions);
        //}
        throw new NotImplementedException();
    }
}

}

4

0 回答 0