Why Serialization performed when using LocalChannel in WCF?
===

There is a WCF sample named [LocalChannel][1] provided by Microsoft to show how a custom binding can be implemented to bypass unnecessary overhead when calling a service in the same ApplicationDomain. It the sample description it is stated that:

> This is useful for scenarios where the client and the service are running in the same application domain and the overhead of the typical WCF channel stack (serialization and deserialization of messages) must be avoided.

I have used this code in my project, but despite the claim it seems that serialization takes place when a service is being called. 

To make it more clear I have changed the code into the following to use a data contract, so it can be easily determined if serialization is being performed or not.

    
    # region Service Contract

    [ServiceContract]
    public interface IGetPrice
    {
        [OperationContract]
        ProductDTO GetPriceForProduct(int productCode);
    }


    [DataContract]
    public class ProductDTO
    {
        private string _price;

        public ProductDTO(string price)
        {
            _price = price;
        }

        #region Overrides of Object

        public override string ToString()
        {
            return string.Format("Price = '{0}'", _price);
        }

        #endregion

        [DataMember]
        public string Price
        {
            get { return _price; }
            set { _price = value; }
        }
    }

    public class GetPrice : IGetPrice
    {
        #region IGetPrice Members

        public ProductDTO GetPriceForProduct(int productId)
        {
            return new ProductDTO((String.Format("The price of product Id {0} is ${1}.",
                                                 productId, new Random().Next(50, 100))));
        }

        #endregion
    }

    # endregion

 

    internal class Program
    {
        private static void Main(string[] args)
        {
            var baseAddress = "net.local://localhost:8080/GetPriceService";

            // Start the service host
            var host = new ServiceHost(typeof (GetPrice), new Uri(baseAddress));
            host.AddServiceEndpoint(typeof (IGetPrice), new LocalBinding(), "");
            host.Open();
            Console.WriteLine("In-process service is now running...\n");

            // Start the client
            var channelFactory
                = new ChannelFactory<IGetPrice>(new LocalBinding(), baseAddress);
            var proxy = channelFactory.CreateChannel();

            // Calling in-process service
            var priceForProduct = proxy.GetPriceForProduct(101);
            Console.WriteLine("Calling in-process service to get the price of product Id {0}: \n\t {1}"
                              , 101, priceForProduct);
            Console.WriteLine("Calling in-process service to get the price of product Id {0}: \n\t {1}"
                              , 202, proxy.GetPriceForProduct(202));
            Console.WriteLine("Calling in-process service to get the price of product Id {0}: \n\t {1}"
                              , 303, proxy.GetPriceForProduct(303));

            Console.WriteLine("\nPress <ENTER> to terminate...");
            Console.ReadLine();
        }
    }




Running this code indicates that 'Price' property of 'ProductDTO' class is being serialized and deserialized during calls via localbinding! 

Has anyone used this method before or know if something is wrong?

  [1]: http://msdn.microsoft.com/en-us/library/ee818240.aspx