I have created a very simple server and client console app demonstrating the issue I have in that I am trying to bring an instance of a serializable object across to the client but it fails on the server.

What am I missing?? I am NOT concerned right now having it Service orientated using DataContracts - I am simply trying to understand why the code as it stands doesn't bring the EJob accross to the client (it DOES however calls the 'Hello from the server' message)

Many thanks.

EDIT

Even if I decorate the EJob class with a DataContract attribute (like below) it STILL doesn't work - the object I receive on the client has LastName set to null?????

```
[DataContract]
public class EJob
{
    [DataMember]
    public string LastName = "Smith";
}

```

**SERVER**

```
namespace testServer
{
    [ServiceContract()]
    public interface IRemoteClient
    {
        [OperationContract]
        void SayHi(string msg);

        [OperationContract]
        void ProcessJob(EJob job);
    }

    [Serializable()]
    public class EJob
    {
        public string LastName = "Smith";
    }

    class Program
    {
        static void Main(string[] args)
        {
            MngrServer.SendJob();
        }
    }

    public class MngrServer
    {
        public static void SendJob()
        {
            try
            {
                // send this off to the correct exe
                NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

                string address = string.Format("net.tcp://localhost:33888/BatchMananger/client");
                EndpointAddress epa = new EndpointAddress(address);

                // create the proxy pointing to the correct exe
                IRemoteClient clientProxy = ChannelFactory<IRemoteClient>.CreateChannel(binding, epa);

                clientProxy.SayHi("Hello from server");  <-- THIS WORKS FINE

                EJob job = new EJob { LastName = "Janssen" };

                clientProxy.ProcessJob(job);             <-- THIS RAISES AN EXCEPTION see below...
            }
            catch (Exception ex)
            {
                string msg = ex.Message;

                //The formatter threw an exception while trying to deserialize the message: There was an error while 
                //trying to deserialize parameter http://tempuri.org/:job. The InnerException message was ''EndElement' 'job' 
                //from namespace 'http://tempuri.org/' is not expected. Expecting element 'LastName'.'.  
            }

        }
    }

}

```

**CLIENT**

```
namespace testClient
{
    [ServiceContract()]
    public interface IRemoteClient
    {
        [OperationContract]
        void SayHi(string msg);

        [OperationContract]
        void ProcessJob(EJob job);
    }

    [Serializable()]
    public class EJob 
    {
        public string LastName = "Smith";
    }

    class Program
    {
        static void Main(string[] args)
        {
            MngrClient.Prepare();
            Console.ReadLine();
        }
    }

    /// <summary>
    /// STATIC / INSTANCE 
    /// </summary>
    public class MngrClient : IRemoteClient
    {
        public void SayHi(string msg)
        {
            Console.WriteLine(msg);
        }

        public void ProcessJob(EJob job)
        {
            Console.WriteLine(job.LastName);
        }

        public static void Prepare()
        {
            // allow this class to be used! - so instances are created and info directly passed on to its static members.
            ServiceHost sh = new ServiceHost(typeof(MngrClient));

            // create the net binding
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

            // define the tcpaddress
            string address = string.Format("net.tcp://localhost:33888/BatchMananger/client");

            // add a service point so my server can reach me
            sh.AddServiceEndpoint(typeof(IRemoteClient), binding, address);

            // now open the service for business
            sh.Open();
        }

    }

}

```