I was wondering how to add the DataContract to my service? I mean, I know I have to create a class, put [DATACONTRACT] on top of it and then add [DATAMEMBER] on top of each members, but then how to add the DataContract to the service (I already have a [ServiceContract] and [OperationContract] running on a service)??
I am doing everything programmaticaly at the moment (no .config file).
some piece of code showing how I launch and add my OperationContract: (I'm using .NET 4.0)
Service side:
using (ServiceHost host = new ServiceHost(typeof(StringReverser), new Uri[]{ new Uri("net.tcp://localhost") }))
{
host.AddServiceEndpoint(typeof(IStringReverser), new NetTcpBinding(), "TCPReverse");
host.Open();
}
Client side:
Callbacks myCallbacks = new Callbacks();
DuplexChannelFactory<IStringReverser> TCPFactory =
new DuplexChannelFactory<IStringReverser>(
myCallbacks,
new NetTcpBinding());
TCPFactory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "password");
IStringReverser TCPProxy = TCPFactory.CreateChannel();
Console.WriteLine("Client connected");
Thanks in advance