0

We have a stateful service that saves data in a ReliableDictionary. We noticed a small amount of data missing from this service today.

We had a recent code update which changed the namespace and assembly of one of the models that was stored in the dictionary, however the data contract itself was unchanged.

Before:

namespace MainProject.StatefulService.Models
{
   [DataContract]
   public class ColorElement
   {
      [DataMember(Name = "Color")]
      private readonly Color color;

      // Shortened for clarity.
   }
}

After:

namespace MainProject.Models
{
   [DataContract]
   public class ColorElement
   {
      [DataMember(Name = "Color")]
      private readonly Color color;

      // Shortened for clarity.
   }
}

Is there any way that changing the assembly/namespace of a model could cause problems in the reliable dictionary?

Sam Schneider
  • 202
  • 4
  • 12

1 Answers1

1

As described here: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-application-upgrade-data-serialization

Changing the class name or namespace will affect your serialization format.

I have not experimented with it, but i would assume that if you specify name and namespace in your datacontract attribute those will be in the serialized format instead of the class and assembly namespace so that any changes to the class later won't affect the serialization format - but this is just speculation based on what i am used to with WCF and not anything fabric related.

Esben Bach
  • 664
  • 4
  • 23
  • 1
    Forgot to add that if you need to change the format somehow, you should probably hook into the serialization callbacks as described here: https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/version-tolerant-serialization-callbacks and here https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-contract-versioning – Esben Bach Apr 01 '18 at 08:25
  • I had read the Service Fabric documentation you posted, but re-reading I see now that it clearly lists "Changing the class name or namespace" as one of the "Code changes that result in a data format change". – Sam Schneider Apr 02 '18 at 10:09