NServiceBus System.ArgumentNullException

时间:2014-02-26 21:30:48

标签: c# msmq nservicebus

我是NServiceBus(和绿色开发人员)的新手,我被这个异常摧毁了(在NSB控制台中,在调用处理程序之前):

2014-02-26 14:27:10,269 [8] ERROR NServiceBus.Unicast.Transport.TransportReceiver [(null)] <(null)> -
 Failed to deserialize message with ID: b0e459fa-0ada-431c-bbee-a2de00ee2a29
 System.Runtime.Serialization.SerializationException: An error occurred while attempting to extract logical messages
 from transport message NServiceBus.TransportMessage ---> System.ArgumentNullException: Value cannot be null.
Parameter name: path
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionA
ccess access, AccessControlActions control, String[] pathListOrig, Boolean check
ForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.IO.FileSystemInfo.set_Attributes(FileAttributes value)
   at SetIsReadOnly(Object , Object )
   at NServiceBus.Serializers.XML.XmlMessageSerializer.GetObjectOfTypeFromNode(T
ype t, XmlNode node) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core
\Serializers\XML\XmlMessageSerializer.cs:line 492
   at NServiceBus.Serializers.XML.XmlMessageSerializer.GetPropertyValue(Type typ
e, XmlNode n) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core\Serial
izers\XML\XmlMessageSerializer.cs:line 828
   at NServiceBus.Serializers.XML.XmlMessageSerializer.GetObjectOfTypeFromNode(T
ype t, XmlNode node) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBus.Core
\Serializers\XML\XmlMessageSerializer.cs:line 487
   at NServiceBus.Serializers.XML.XmlMessageSerializer.Process(XmlNode node, Obj
ect parent, Type nodeType) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceBu
s.Core\Serializers\XML\XmlMessageSerializer.cs:line 379
   at NServiceBus.Serializers.XML.XmlMessageSerializer.Deserialize(Stream stream
, IList`1 messageTypesToDeserialize) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\
NServiceBus.Core\Serializers\XML\XmlMessageSerializer.cs:line 359
   at NServiceBus.Unicast.Messages.ExtractLogicalMessagesBehavior.Extract(Transp
ortMessage physicalMessage) in c:\BuildAgent\work\31f8c64a6e8a2d7c\src\NServiceB
us.Core\Unicast\Messages\ExtractLogicalMessagesBehavior.cs:line 74
   at NServiceBus.Unicast.Messages.ExtractLogicalMessagesBehavior.Invoke(Receive
PhysicalMessageContext context, Action next) in c:\BuildAgent\work\31f8c64a6e8a2
d7c\src\NServiceBus.Core\Unicast\Messages\ExtractLogicalMessagesBehavior.cs:line
 52
   --- End of inner exception stack trace ---

我从免费章节中获得了MVC示例项目,但我无法让pubsub示例工作,因为'Host不支持托管多个端点。 我正在破碎的解决方案中处理3个项目,只是试图获得一个简单的1节点pub和1节点sub:

  • Core(来自NuGet的NServiceBus.Interfaces 4.4.1,包含带有IFileUploadedEvent.cs的Events文件夹)
  • FileWatcherService(来自NuGet的NServiceBus.Host 4.4.1)
  • FileMoverService(来自NuGet的NServiceBus.Host 4.4.1)

Core \ Events \ IFileUploadedEvent.cs:

using NServiceBus;
using ...

namespace Core.Events
{   public interface IFileUploadedEvent : IEvent
    {   Guid EventId { get; set; }
        string Client { get; set; }
        FileInfo FileName { get; set; }
    }
}

FileWatcherService具有默认的app.config,没有映射。 FileWatcherService.EndpointConfig.cs:

namespace FileWatcherService
{    using NServiceBus;
     public class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher    {}
}

FileWatcherService.FileWatcher.cs:

using NServiceBus;
using Core.Events;
using ...

namespace FileWatcherService
{   public class FileWatcher : IWantToRunWhenBusStartsAndStops
    {   public IBus Bus { get; set; }
        public void Activate()
         { ... }
        ...Stalker, calls PublishFileUploaded
        public void PublishFileUploaded(FileInfo fileName, string clientName)
        {   Bus.Publish<IFileUploadedEvent>(evt =>
            {   evt.EventId = Guid.NewGuid();
                evt.Client = clientName;
                evt.FileName = fileName;
            });
}   }   }

FileMoverService.App.config包含:

  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="Core" Endpoint="FileWatcherService" />
    </MessageEndpointMappings>
  </UnicastBusConfig>

在NSB窗口中,我看到了 FileMover:订阅Core.Events.IFileUploadedEvent FileWatcher:将FileMoverService @ ccc订阅到消息类型Core.Events.IFileUploadedEvent

FileMover类实现IHandleMessages,但代码永远不会达到,因为NServiceBus会抛出第一个错误。

我尝试在EndpointConfig中运行Init(),但我仍然得到相同的错误。 请帮帮我!我做错了什么?

2 个答案:

答案 0 :(得分:0)

原来你无法反序列化FileInfo对象。所以我必须以完全不同的方式解决问题。

答案 1 :(得分:0)

如果您想使用NServiceBus移动文件或其他blob,请查看使用此处描述的“数据总线”功能:

http://docs.particular.net/NServiceBus/attachments-databus-sample