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 8642707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:50:44+00:00 2026-06-12T11:50:44+00:00

I want to transfer BusinessObjects from one PC to another. If I think about

  • 0

I want to transfer BusinessObjects from one PC to another. If I think about a number of around 40 different object types to transfer the use of many contracts for the different objects would seem to be quite some overload for always the same task: “Send Object A to Computer B and save object to DB” (objects all have a persistent method).

As the Objects can have many different types, I only want to to use a generic method to:

  1. serialize a BO object
  2. transfer it to another PC
  3. deserialize it with correct type
  4. make a consistency check
  5. save to db
  6. is my problem.

At the moment I’m thinking about sending the type as eytra information.
Then I want to do something like:

BinaryFormatter aFormatter = new BinaryFormatter();
aFormatter.AssemblyFormat = System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
Object.ParseTypeFromString(aObjektType) aObject = aFormatter.Deserialize(stream) as Object.ParseTypeFromString(aObjektType);

And afterwards just use generic methods from a base object to save object to database, to keep the transfer classes as simple as possible.

Is there a possibility to do something like this? Or am I going in a completly wrong direction and it would be easier to achieve this task with another approach?

  • 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-06-12T11:50:46+00:00Added an answer on June 12, 2026 at 11:50 am

    If you don’t know the type in advance, you cannot currently be doing anything in the C# that depends on the type. BinaryFormatter will already be deserializing it with the correct object type, but you code can usually just refer to the object as…. object:

    object aObject = aFormatter.Deserialize(stream);
    

    At this point, there are various options available to you:

    • use a common interface / base-class
    • use dynamic (interesting uses of dynamic include calling the most appropriate overload of a method, and switching into a generic method)
    • test the type explicitly with is, as or GetType(), for special-casing

    As an example of the middle option:

    object aObject = aFormatter.Deserialize(stream);
    GenericMagic((dynamic)aObject);
    OverloadMagic((dynamic)aObject);
    
    ...
    
    void GenericMagic<T>(T obj) // possibly some constraints here too
    {
        T x = ... // now we *have* the type, but as `T`;
                  // of course, you still can't do many exciting
                  // things unless you add constraints
    }
    
    // the correct one of these will be chosen at runtime...
    void OverloadMagic(Customer cust) {...}
    void OverloadMagic(User user) {...}
    void OverloadMagic(Order order) {...}
    

    Frankly, if I’ve had to deserialize (etc) something unknown I usually prefer to stay non-generic, just using object, GetType(), and maybe some reflection – it is still generic, even if it doesn’t use generics.

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

Sidebar

Related Questions

I want to transfer files from one directory to another using streamreader and writer
I want to transfer the data from one table in sql to another is
I want to transfer a String value from one class to another class in
I want to transfer a data from one webpage to another page. But I
I want to transfer one asp.net page form values to another page when i
I am new to wordpress and i want to transfer data from one page
I have 2 servers. And i want to transfer a file from one server
Okay. I want to transfer a number of templates from an Expression Blend Silverlight
I want to transfer a file from 1 php server (A) to another php
Where does eclipse keep it's key-binding settings? I want to transfer them from one

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.