ListenUriMode 枚举


指示传输是否必须保证提供给服务的供服务侦听的 URI 是唯一的,或者不对该 URI 进行任何修改,就原样使用。Indicates whether the transport must ensure that the URI provided for the service to listen on is unique or can be used exactly as provided.

public enum class ListenUriMode
public enum ListenUriMode
type ListenUriMode = 
Public Enum ListenUriMode


Explicit 0

完全原样使用 ListenUriUses the ListenUri exactly as provided. 这是默认值。This is the default value.

Unique 1

指定传输是否应使用特定传输机制,以确保 ListenUri 是唯一的。Specifies that the transport should use a transport-specific mechanism to ensure that the ListenUri is unique.


可以使用 ListenUri 属性,以编程方式对服务要侦听的终结点的 URI 进行设置;还可以使用 ListenUriMode 属性来设置该终结点的 ListenUriMode 的值。The URI for the endpoint on which a service listens can be set programmatically using the ListenUri property and the value of the ListenUriMode for that endpoint is set using the ListenUriMode property. ListenUri 的默认值为 AddressThe default value for ListenUri is Address. 的默认值ListenUriMode为 Explicit。The default value for ListenUriMode is Explicit.

另外,也可使用 ListenUri 属性和 ListenUriMode 属性来设置这些属性的值。The value of these properties may also be set using the ListenUri property and the ListenUriMode property.

当的ListenUriMode值设置为 Unique 时, 传输负责创建唯一 URI。When the value of the ListenUriMode is set to Unique the transport is responsible for creating a unique URI. Windows Communication Foundation (WCF) 使用的不同传输以不同方式生成此唯一 URIDifferent transports used by Windows Communication Foundation (WCF) generate this unique URI differently

  • 对于独占模式下的 TCP(PortSharingEnabledfalse),这意味着绑定到一个唯一可用端口号。For TCP in exclusive mode (PortSharingEnabled is false) this means binding to a uniquely available port number.

  • 对于端口共享模式下的 TCPPortSharingEnabled ( true为) 以及所有其他现有 WCF 传输, 这意味着将唯一路径 (GUID) 追加ListenUri到的末尾。For TCP in port sharing mode (PortSharingEnabled is true) and for all of the other existing WCF transports, this means appending a unique path (a GUID) to the end of the ListenUri.

当的值ListenUriMode设置为 Explicit 模式时, 传输使用完全按照提供的ListenUri方式, 而无需对其进行修改以使其唯一。When the value of the ListenUriMode is set to Explicit mode, the transport uses the ListenUri exactly as it is provided, without modifying it to make it unique.