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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:57:20+00:00 2026-05-30T20:57:20+00:00

I have the following code namespace A { [DataContract] public class CustomClass {} }

  • 0

I have the following code

namespace A
{
    [DataContract]
    public class CustomClass {}
}

how could I decorate the DataContract attribute, or what I must change on server side to change the code into

namespace B
{
    [DataContract(...)]
    public class CustomClass {}
}

and all existing clients to connect without problems to this client.

Note: I can’t change any client, only on server side.

  • 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-30T20:57:22+00:00Added an answer on May 30, 2026 at 8:57 pm

    That depends on what binding (and more specifically, which serializer) you are using. If you are using DataContractSerializer, then the answer is simple: do nothing. Those two contracts are equivalent; the wire data is defined by:

    • the explicit name in [DataContract(...)], if one – else the class name (which matches)
    • the explicit xml namespace in [DataContract(...)]

    If you are using NetDataContractSerializer, simple: you can’t.

    Note that the c# namespace used at the client is entirely up to the client, and is typically determined by the tooling used to generate the type. Frankly, it doesn’t matter what the client uses as the c# namespace, as long as they are using a contract-based serializer such as XmlSerializer or DataContractSerializer.

    To illustrate this: this prints the same thing twice:

    using System.Runtime.Serialization;
    using System;
    namespace A
    {
        [DataContract] class Foo { }
    }
    namespace B
    {
        [DataContract] class Foo { }
    }
    static class Program
    {
        static void Main()
        {
            new DataContractSerializer(typeof (A.Foo)).WriteObject(
                  Console.OpenStandardOutput(), new A.Foo());
            Console.WriteLine();
            new DataContractSerializer(typeof (B.Foo)).WriteObject(
                  Console.OpenStandardOutput(), new B.Foo());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: [DataContract(Namespace = )] public class User { [DataMember] public
I have been sharing database variables using the following code: Namespace DataAccessVariables Public Class
I have the following C# code: namespace ISeeOptic.BL { public abstract class Process {
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
I have the following code compiled by gcc: #include <iostream> using namespace std; class
I have the following (C#) code namespace A { public interface IX { bool
I have following code: #include <iostream> using namespace std; template<class T> T max(T *data,int
I have the following code: #include <iostream> using namespace std; class testing{ int test()
So I have the following the code: namespace ConsoleApplication1 { public delegate int Transformer(int
I have the following code : #include <cstdarg> #include <iostream> using namespace std; class

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.