NServiceBus - 空引用异常。响应处理程序失败

时间:2013-02-28 14:50:59

标签: .net nservicebus nullreferenceexception

以下是我尝试处理邮件时收到的错误消息片段。有什么我想念的。

 2013-02-28 09:17:35,362 [Worker.5] INFO  NServiceBus.Unicast.UnicastBus [(null)]     <(null)> - Received message AIS.TestApp.Messaging.GDataStatusResponse, AIS.TestApp.GCommon, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null with ID 7e7f5048-9f17-4d27-8499-42e92520ed42\32912973 from sender gca-gdata-service
    2013-02-28 09:17:35,394 [Worker.5] ERROR NServiceBus.Unicast.UnicastBus [(null)]
     <(null)> - ResponseHandler Failed handling message.
    System.NullReferenceException: Object reference not set to an instance of an object.
       at NServiceBus.Unicast.UnicastBus.<>c__DisplayClass10`1.<GetAction>b__f(Object o) in d:\BuildAgent-03\work\d692fe98ef9a76ca\src\unicast\NServiceBus.Unicast\UnicastBus.cs:line 909
       at NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.NServiceBus.ObjectBuilder.IBuilder.BuildAndDispatch(Type typeToBuild, Action`1 action) in d:\BuildAgent-03\work\d692fe98ef9a76ca\src\impl\ObjectBuilder.Common\ObjectBuilder.Common\C
    ommonObjectBuilder.cs:line 117

这是我在IWantToRunAtStartup的Run方法中初始化我的总线的方法

Configure.With()
                    .Log4Net()
                    .DefaultBuilder()
                    .XmlSerializer(NServiceBusCommon.XmlSerializerNamespace)
                    .MsmqTransport()
                    .UnicastBus()
                    .CreateBus()
                    .Start();

以下是我尝试处理请求的代码

public class ResponseHandler : IHandleMessages<GDataStatusResponse>,
    IHandleMessages<GDataReply>
{
    public void Handle(GDataStatusResponse message)
    {
            ....
    }
}

如果您需要任何进一步的信息,请与我们联系。

由于  NISHANT

1 个答案:

答案 0 :(得分:1)

初始化不是在IWantToRunAtStartup

中完成的

以下是如何初始化端点的示例:

class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
    public void Init()
    {
        NServiceBus.Configure.With()
            .Log4Net()
            .DefaultBuilder()
            .XmlSerializer(NServiceBusCommon.XmlSerializerNamespace)
            .MsmqTransport()
            .UnicastBus()
    }
}

有关详细信息,请参阅http://support.nservicebus.com/customer/portal/articles/856698