0
votes

I'm new to NServiceBus (and a green developer) and I'm getting destroyed by this exception (in the NSB console, before calling the handler):

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 ---

I got the MVC Example project working from the free chapters, but I couldn't get the pubsub example to work because 'Host doesn't support hosting of multiple endpoints.' I'm working in 3 projects in my broken solution, just trying to get a simple 1-node pub and 1-node sub going:

  • Core (NServiceBus.Interfaces 4.4.1 from NuGet, contains Events folder with IFileUploadedEvent.cs)
  • FileWatcherService (NServiceBus.Host 4.4.1 from NuGet)
  • FileMoverService (NServiceBus.Host 4.4.1 from NuGet)

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 has default app.config, no mappings. 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;
            });
}   }   }

the FileMoverService.App.config contains:

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

In the NSB windows, I see FileMover: Subscribing to Core.Events.IFileUploadedEvent FileWatcher: Subscribing FileMoverService@ccc to message type Core.Events.IFileUploadedEvent

The FileMover class implements IHandleMessages, but the code never reaches that because NServiceBus throws the first error.

I tried running Init() in the EndpointConfig, but I still get the same error. Help me Please! What am I doing wrong?

2
No idea about NServiceBus but the key here will be to figure out what the path is that's null in System.ArgumentNullException: Value cannot be null. Parameter name: path After you find that out the next question is why it is null. Can you step through the code to narrow it down somehow?Joanna Derks
Thanks for replying! When I look at the object being sent, the objects are not null, so I'm leaning towards something being configured wrong between MSMQ and UnicastBus. Let me go see if I can find something more on that path. Brb.TurtleDev
THat was super helpful! I changed the event to have just a string, and it passes that just fine. So the issue is my event object and the data types. Thanks Joanna! You Rock!TurtleDev
I'm glad you found it :-)Joanna Derks
BTW: the exception is thrown when the app is trying to access some sort of a file. It looks slightly like a missing config value to point the app to the right place? Do you have any idea what file that is?Joanna Derks

2 Answers

0
votes

If you want to move files or other blobs using NServiceBus, look at using our "data bus" capabilities described here:

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

0
votes

Turns out you can't Deserialize a FileInfo object. So I'll have to approach the problem completely differently.