RawRabbit icon indicating copy to clipboard operation
RawRabbit copied to clipboard

Subscribing in a different project than publishing, skipping strict type checks

Open carol-braileanu opened this issue 7 years ago • 1 comments

I have a subscriber in a .NET core project, listening for an object called Notification. I have a publisher that must be in a .NET 4.6 project. I copied the Notification contract from .NET Core to .NET, and I tried to publish it to the queue. The Notification classes in both projects are identical, and my code is:

queuingService.BusClient.PublishAsync(not, Guid.NewGuid(), cfg => { cfg.WithExchange(e => e.WithName("flowconcept.domaincontracts")); cfg.WithRoutingKey("notification.#"); }).Wait();

However, I am running into a JSON serialization error:

Newtonsoft.Json.JsonSerializationException: Error resolving type specified in JSON 'FlowConcept.DomainContracts.Notification, DeltaStore.Core'. Path '$type', line 1, position 78. ---> System.IO.FileNotFoundException: Could not load file or assembly 'DeltaStore.Core, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Is there a way to disable these strict type checks?

carol-braileanu avatar Sep 25 '18 12:09 carol-braileanu

Hello - yes! By default TypeNameHandling.Auto is used. From the official documentation

Include the .NET type name when the type of the object being serialized is not the same as its declared type

If this doesn't work for you, you could explicitly register a serializer in RawRabbit with TypeNameHandling.None and you should be good to go.

pardahlman avatar Sep 28 '18 05:09 pardahlman