Alex Rivera | Logout

How to send object through NamedPipe in .NET 3.5?

Asked 2009-07-26T17:51:01.527
11

Can you tell me what's the best way to send objects through NamedPipes in .net 3.5?

Edit
Report

1 Answer

1

What you are looking for is DataContract attribute. See also: MSDN Using Data Contracts.

A data contract is a formal agreement between a service and a client that abstractly describes the data to be exchanged. That is, to communicate, the client and the service do not have to share the same types, only the same data contracts. A data contract precisely defines, for each parameter or return type, what data is serialized (turned into XML) to be exchanged.

Your service contract:

[ServiceContract]
public interface IApplicationRegistration
{
    // Sends the application information
    [OperationContract]
    bool RegisterApplication(AppInfo appInfo);
}

The data to exchange:

[DataContract]
public class AppInfo
{
    private int _processID;
    private string _processName;

    [DataMember]
    public int ProcessID
    {
        get { return _processID; }
        set { _processID = value; }
    }

    [DataMember]
    public string ProcessName
    {
        get { return _processName; }
        set { _processName= value; }
    }
}
answered 2009-07-26T19:06:18.863

Your Answer