Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Global.asax问题中的自动映射配置_C#_Asp.net_Asp.net Mvc_Asp.net Mvc 4_Automapper - Fatal编程技术网

C# Global.asax问题中的自动映射配置

C# Global.asax问题中的自动映射配置,c#,asp.net,asp.net-mvc,asp.net-mvc-4,automapper,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Automapper,我有一个MVC4应用程序(.NET 4.5)。我在这个项目中有两个数据类: public class Address { public string StreetNumber { get; set; } public string StreetName { get; set; } public string City { get; set; } public string County { get; set; } public string State {

我有一个MVC4应用程序(.NET 4.5)。我在这个项目中有两个数据类:

public class Address
{
    public string StreetNumber { get; set; }
    public string StreetName { get; set; }
    public string City { get; set; }
    public string County { get; set; }
    public string State { get; set; }
}

public class OrderDetail
{
    public int Id { get; set; }
    public string StreetNumber { get; set; }
    public string StreetName { get; set; }
    public string City { get; set; }
    public string County { get; set; }
    public string State { get; set; }
    public string CustomerEmail { get; set; }
    public DateTime InsertTimeStamp { get; set; }
    public bool IsProcessed { get; set; }
    public DateTime? ProcessedTimeStamp { get; set; }
}
我正在使用AutoMapper从OrderDetail映射到Address类,如下所示

public class OrderDetailToAddressMappingProfile : Profile
{
    protected override void Configure()
    {
        Mapper.CreateMap<OrderDetail, Address>();
    }
}

public static class AutoMapperMvcConfiguration
{
    public static void Configure()
    {
        Mapper.Initialize(x =>
            {
                x.AddProfile<OrderDetailToAddressMappingProfile>();
                x.AddProfile<AddressToPropertyAddressMappingProfile>();
            });
    }
}

我尝试将应用程序启动方法的签名更改为

public void Application_Start(object sender, EventArgs e)
protected override void Application_Start(object sender, EventArgs e) 
正如@WiktorZychla所建议的,但是我得到了一个警告,它在springmvcapapplication类中隐藏了相同的方法。然后,我试图通过将方法签名更改为来覆盖SpringMVCapApplication中的应用程序启动虚拟方法

public void Application_Start(object sender, EventArgs e)
protected override void Application_Start(object sender, EventArgs e) 

这就成功了。

EDIT:Uggghh。我真的应该学会正确地阅读问题。将整个Automapper消息粘贴到此处。请共享您使用映射的代码以及异常的完整堆栈跟踪(不仅仅是消息)。@SimonWhitehead:添加了堆栈跟踪。您的全局类是否从其他类继承?或者是标准库存?将应用程序开始更改为
public void application\u开始(对象发送者,事件参数)