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

The Archive Base Latest Questions

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

Possible Duplicate: How to XML deserialize an object of Unknown Type? I’ve just started

  • 0

Possible Duplicate:
How to XML deserialize an object of Unknown Type?

I’ve just started playing with serializing and deserializing.

I have a model of type Person, with only 2 properties (Name and Age), I can serialise to XML. When it comes to deserialise, as far as I know, I have to tell the compiler that the type is Person. With the world of generic T, this seems counter productive. I would have thought I could establish the object as a ‘InMemoryOnly’ object (if you can imagine it) where the object is created at run time, as is it’s parameters/fields/properties etc, all based upon the XML. Maybe like an anonymous type; I appreciate that the C# compiler would have to ignore this during design time and that we’d lose intellisense but as all objects are passed to memory any way, I can’t see why it would fail at run time. Or maybe this would be possible with Reflection?

Any way, that is what I’m trying to do, deserialise from XML to a generic object. Is this possible with C#?

EDIT Just found a dupe so the question now is about why can’t C# (.NET) do this? I know the answer is probably “because it doesn’t” but my question is COULD it be possible or would be more trouble than it’s worth for the programmer?

The reason for this is, as far as I know, to accomplish this means the serialise and de-serialize has to know the type (in this case, Person). So, if the serailise and deserialize happen over WCF (where serialize and serialize happen in different assemblies) then the Person object has to be duplicated (and this is against the DRY principle)

  • 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-12T19:36:45+00:00Added an answer on June 12, 2026 at 7:36 pm

    The WCF sample does not demonstrate a valid reason to do this.
    You simply could – and can! – put the Person class in an assembly that is used by both the server and the client. That’s how I do it when using WCF.
    If you don’t want to do this, Visual Studio offers to automatically generate the types used in the service when you add a service reference.
    In both cases, you have to update the Person class in one place only.

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

Sidebar

Related Questions

Possible Duplicate: How to Deserialize XML document Suppose that I have a class that
Possible Duplicate: Import XML to SQL using C# I just downloaded about 3000 XML
Possible Duplicate: Deserializing XML, how do I access attributes? I am deserializing the following
Possible Duplicate: Use Linq to Xml with Xml namespaces I have an xml: <?xml
Possible Duplicate: Best practices to parse xml files? I have a xml string: <XML>
Possible Duplicate: Parse XML with Namespace using SimpleXML PHP SimpleXML Namespace Problem <?php header(Content-Type:
Possible Duplicate: Android XML Percent Symbol hi mate i have an array in file
Possible Duplicate: Silverlight XML editor / syntax highlighting Hello, I have some XML in
Possible Duplicate: Parse XML Elements with LINQ I have an XML document that looks
Possible Duplicate: Best XML Parser for PHP I have an XML code like as

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.