none
Azure Cache Service - Failing to Serialize/Deserialize Classes marked with DataContract

    Diskusi Umum

  • We observed this strange behavior while deploying our MVC application as an Azure-hosted service. When we store objects in session that are tagged with DataContractAttribute they don't get serialized properly via the DistributedCacheSessionStateStoreProvider. Essentially, what we discovered is that you cannot use DataContract on items that you store in the Azure Cache. The Azure Cache store will not provide you with any errors either, you just end up with the default object type with default values during retrieval. Any values that should have been stored are missing, but the default object is retrieved.

    While troubleshooting this problem, we did not see this problem in any of the other Session Store providers. We verified InProc, ASP.NET State Server, SQL Server Session, and AppFabric Cache all work perfectly with classes tagged with DataContract. However, it seems Azure Cache uses NetDataContractSerializer which provides some limitations on what types can be stored and retrieved via its cache store.

    Will this be fixed in future Azure Cache version, and why is it not listed publicly as a limitation of the Azure Cache? This costs us 3 days of troubleshooting until we pinpointed the root cause. Hopefully others will benefit from this post.


    30 April 2012 14:55

Semua Balasan