Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1083263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:24:44+00:00 2026-05-16T22:24:44+00:00

Problem: When caching an instance of a class and immediately getting it back out

  • 0

Problem: When caching an instance of a class and immediately getting it back out of cache, i get the object back (its not null), but all of its properties / fields are null or defaults.

    _cacheHelper.PutInCache("testModuleControlInfoOne", mci);
    //mci has populated fields

    var mciFromCacheOne = _cacheHelper.GetFromCache("testModuleControlInfoOne");
    //mciFromCacheOne now has null or default fields

So I suspect the way the object is structured is the problem and AppFabric is not serializing the object properly for some reason.

When I use the following Serialization method however, I get the object back with all properties / fields as they were prior to serialization.

    public T SerializeThenDeserialize<T>(T o) where T : class
    {
            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                bf.Serialize(ms, o);

                ms.Position = 0;

                return (T)bf.Deserialize(ms);
            }
    }

How can an object serialize and deserialize properly using the binary formatter and not do exactly the same thing via caching?

Has anyone encountered this or does anyone have any suggestions or tips on generally what to look out for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:24:45+00:00Added an answer on May 16, 2026 at 10:24 pm

    Ok found it.

    The object implemented IXmlSerializable so AppFabric used that instead of the regular serialization.

    Running it through an XmlSerializer (instead of a BinaryFormatter) gives the same null fields as I was experiencing.

    It seems the IXmlSerializable implementation has issues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use System.Web.Caching.Cache object in my application, but this code throws a
Problem: I have a table that prints out vertical but I would like it
As Anton points out (thanks Anton!) my problem is Association Caching in the tests
I have the following problem, which I think is related to caching but I
ASP.NET Image Caching Problem (How to Disable it?) .IE browser load old image from
Problem: Been struggling to get my code to load external shaders and it is
Problem: I've written State Machine for my android application. It is separate class, extension
I am experiencing a problem with IE caching the results of an action method.
I'm working on a Vista workstation purely out of stubbornness. Not that I like
I've got a caching problem with the Internet Explorer 6.0 and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.