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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:23:14+00:00 2026-06-05T00:23:14+00:00

I have a requirement in which i have to use System.Object as a parameter

  • 0

I have a requirement in which i have to use System.Object as a parameter in WCF. As it is not serializable,I am getting the message as the operation is not supported as it uses System.Object. Any solution to this problem.

  • 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-05T00:23:15+00:00Added an answer on June 5, 2026 at 12:23 am

    When sending messages over the wire, WCF by default will only serialize what’s enough to get the message across, i.e., the members of the contracts. If your message takes an “object” as a parameter, extra information needs to be sent over the wire with the type information. If you use the same assemblies on the client and the server, you can use the NetDataContractSerializer (instead of the default DataContractSerializer) in the server (and the client), and they’ll be able to exchange arbitrary objects, as shown in the code below. But, as @MarcGravell mentioned, this may not be the best usage of WCF…

    The code to enable the NetDataContractSerializer:

    public class Post_8b2c7ad7_b1c3_410b_b907_f25cee637110
    {
        public class Person
        {
            public string Name { get; set; }
            public int Age { get; set; }
            public override string ToString()
            {
                return string.Format("Person[Name={0},Age={1}]", Name, Age);
            }
        }
        [ServiceContract]
        public interface ITest
        {
            [OperationContract]
            object Echo(object obj);
        }
        public class Service : ITest
        {
            public object Echo(object obj)
            {
                return obj;
            }
        }
        public class ReplaceSerializerOperationBehavior : DataContractSerializerOperationBehavior
        {
            public ReplaceSerializerOperationBehavior(OperationDescription operation)
                : base(operation)
            {
            }
            public override XmlObjectSerializer CreateSerializer(Type type, string name, string ns, IList<Type> knownTypes)
            {
                return new NetDataContractSerializer(name, ns);
            }
            public override XmlObjectSerializer CreateSerializer(Type type, XmlDictionaryString name, XmlDictionaryString ns, IList<Type> knownTypes)
            {
                return new NetDataContractSerializer(name, ns);
            }
            public static void ReplaceSerializer(ServiceEndpoint endpoint)
            {
                foreach (var operation in endpoint.Contract.Operations)
                {
                    for (int i = 0; i < operation.Behaviors.Count; i++)
                    {
                        if (operation.Behaviors[i] is DataContractSerializerOperationBehavior)
                        {
                            operation.Behaviors[i] = new ReplaceSerializerOperationBehavior(operation);
                            break;
                        }
                    }
                }
            }
        }
        public static void Test()
        {
            string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
            ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress));
            var endpoint = host.AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "");
            ReplaceSerializerOperationBehavior.ReplaceSerializer(endpoint);
            host.Open();
            Console.WriteLine("Host opened");
    
            ChannelFactory<ITest> factory = new ChannelFactory<ITest>(new BasicHttpBinding(), new EndpointAddress(baseAddress));
            ReplaceSerializerOperationBehavior.ReplaceSerializer(factory.Endpoint);
            ITest proxy = factory.CreateChannel();
            Console.WriteLine(proxy.Echo("Hello"));
            Console.WriteLine(proxy.Echo(123.456));
            Console.WriteLine(proxy.Echo(new Uri("http://tempuri.org")));
            Console.WriteLine(proxy.Echo(new Person { Name = "John Doe", Age = 33 }));
    
            ((IClientChannel)proxy).Close();
            factory.Close();
    
            Console.Write("Press ENTER to close the host");
            Console.ReadLine();
            host.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a requirement which I have to implement autocomplete, but I'm not sure
I have an ASP MVC application which I also use (as a requirement) as
I have a requirement which needs to go to a webpage and take a
Good day, I have a requirement which i need to include a layout (actually
I have a unique requirement which I need to meet to with sitecore, and
I am new to IOS development.. I have a requirement in which i need
I have a data storage requirement which is an excellent candidate for single instance
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
I have a requirement in my application in which I have to send MMS
I have a requirement to design a Web Application which acts as a Facade

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.