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

  • Home
  • SEARCH
  • 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 912551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:24:05+00:00 2026-05-15T17:24:05+00:00

our task is quite simple, we have an object graph where each object (IDItem)

  • 0

our task is quite simple, we have an object graph where each object (IDItem) has a unique ID.
The object graph exists two times, on the client and on the server machine.

Now we pass some serializable commands to the server. The command has as fields some of the IDItems. The IDItems implement the ISerializable interface and only store their ID in the SerializationInfo. Like:

// The method called when serializing a IDItem.
void GetObjectData(SerializationInfo info, StreamingContext context)
{
    // Instead of serializing this object, just save the ID
    info.AddValue("ID", this.GetID());
}

The problem is, how can we assign the existing object to the instance that the deserializer creates? Obviously something like the following in the ISerializable constructor does not work, because the ‘this’ identifier is read only:

//does not work   
protected IDItem(SerializationInfo info, StreamingContext context)
{
    this = GlobalObject.GetIDItem(info.GetString("ID"));
}

So any idea how we can Assign an existing object to the deserialized object?

Best Regards,
thalm

  • 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-15T17:24:05+00:00Added an answer on May 15, 2026 at 5:24 pm

    You might be able to do it by creating a proxy object that implements IObjectReference and performs the fake deserialization.

    (Your proxy object would need to exist on both the client and server, and I suppose that your type versioning etc would also need to be exactly the same on both.)

    [Serializable]
    public class Example : ISerializable
    {
        // ...
    
        void ISerializable.GetObjectData(
            SerializationInfo info, StreamingContext context)
        {
            info.SetType(typeof(ExampleDeserializationProxy));
            info.AddValue("ID", this.GetID());
        }
    }
    
    // ...
    
    [Serializable]
    public class ExampleDeserializationProxy : IObjectReference, ISerializable
    {
        private readonly int _id;
    
        private ExampleDeserializationProxy(
            SerializationInfo info, StreamingContext context)
        {
            _id = info.GetInt32("ID");
        }
    
        object IObjectReference.GetRealObject(StreamingContext context)
        {
            return GlobalObject.GetIDItem(_id);
        }
    
        void ISerializable.GetObjectData(
            SerializationInfo info, StreamingContext context)
        {
            throw new NotSupportedException("Don't serialize me!");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Task: I have a camera mounted on the end of our assembly line, which
I'm using nant to build our product and have written a custom task to
I have MSbuild task like this to sign all the output modules of our
We have around 80 jars in our applications. All are created using javac task
We are starting to use Redmine as our task tracking tool and for some
we're transitioning to doing all our task tracking in TFS 2010 and I'm wondering
I was given the task of doing a facelift to our current site. I
So, I've got task from my boss to install opendocman on our newly installed
Today at work, I was given a task to fix a bug within our
We're using Quartz.Net to schedule about two hundred repeating jobs. Each job uses the

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.