2013-02-28 79 views
1

以下是我嘗試處理消息時得到的錯誤消息片段。有什麼我失蹤了。NServiceBus - 空引用異常。響應處理程序失敗

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

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

下面的Run方法中初始化我的車就是我試圖處理請求

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

代碼請讓我知道你是否需要任何進一步的信息。

感謝 NISHANT

回答

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

+0

約翰,我已經實現了接口IConfigureThisEndpoint但它留空白的總線在已初始化運行方法 – Nishant 2013-03-01 04:43:28

+0

謝謝約翰。我沒有讀你的第一行。將初始化代碼移動到Init方法,它工作! – Nishant 2013-03-01 13:51:40

相關問題