ServiceHostBase.AddServiceEndpoint Method (ServiceEndpoint)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Adds the specified service endpoint to the hosted service.

Namespace:   System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public virtual void AddServiceEndpoint(
	ServiceEndpoint endpoint


Type: System.ServiceModel.Description.ServiceEndpoint

The service endpoint.

Exception Condition

Endpoint is null.


The host is not in a Created or an Opening state or there is no ServiceDescription for the hosted service.


The Address, Binding, or Contract property is null.

When using the method, the service host does a "by-configuration-name" validation on the contract description. In other words, the host verifies that ConfigurationName exists in the list of configuration names of the service contracts implemented by the service. If the validation passes, the description in the ServiceEndpoint is used as it is, even if the ContractDescription reflected from the service is different.

As an example, assume that the description in the ServiceEndpoint and the contract description reflected from the service have the same name, but different operation behaviors. The implication of only “by-configuration-name” validation is that there is no validation that the behaviors are the same and there are one updates to one description because of another description.

If the address is a relative URI, one of the base addresses of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.

.NET Framework
Available since 4.0
Return to top