Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

NetTcpBinding Constructor (SecurityMode)

Initializes a new instance of the NetTcpBinding class with the type of security used specified.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public NetTcpBinding(
	SecurityMode securityMode
)

Parameters

securityMode
Type: System.ServiceModel.SecurityMode

The SecurityMode value that specifies the type of security used with the binding.

Use this constructor when you want to configure the security. If you want to configure security and enable reliable sessions, use NetTcpBinding.NetTcpBinding(SecurityMode, Boolean).

This example shows how to create a NetTcpBinding using the security mode parameter.

	    NetTcpBinding bSecurity = new NetTcpBinding(SecurityMode.Transport);
// Create the binding for an endpoint.
NetTcpBinding b = new NetTcpBinding();
b.Security.Mode = SecurityMode.Message;

// Create the ServiceHost for a calculator.
Uri baseUri = new Uri("net.tcp://MachineName/tcpBase");
Uri[] baseAddresses = new Uri[] { baseUri };
ServiceHost sh = new ServiceHost(typeof(Calculator), baseAddresses);

// Add an endpoint using the binding and a new address.
Type c = typeof(ICalculator);
sh.AddServiceEndpoint(c, b, "MyEndpoint");

// Set a certificate as the credential for the service.
sh.Credentials.ServiceCertificate.SetCertificate(
    StoreLocation.LocalMachine, 
    StoreName.My, 
    X509FindType.FindBySubjectName, 
    "client.com"); 
sh.Open();

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Store apps

Supported in: Windows 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.