共用方式為


ChannelDispatcher.ManualAddressing 屬性

定義

取得或設定值,這個值會指出通道發送器是否將定址標頭加入至要求-回覆訊息。

public:
 property bool ManualAddressing { bool get(); void set(bool value); };
public bool ManualAddressing { get; set; }
member this.ManualAddressing : bool with get, set
Public Property ManualAddressing As Boolean

屬性值

Boolean

如果 Proxy 不會加入任何定址標頭,則為 true,否則為 false。 預設為 false

例外狀況

通訊物件處於 OpeningOpened 狀態中。

通訊物件處於 ClosingClosed 狀態中。

通訊物件處於 Faulted 狀態中。

範例

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

serviceHost.Open();

IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);

bool isManualAddressing = dispatcher.ManualAddressing;
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

serviceHost.Open()

Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)

Dim isManualAddressing As Boolean = dispatcher.ManualAddressing

備註

只有在 ChannelDispatcher 的執行個體處於 Created 狀態時才可以設定這個屬性,因為這是唯一同時處於可變動且尚未處置的狀態。

如果您不要讓用戶端將訊息識別碼 (Message ID) 和回覆 (ReplyTo) 等定址標頭加入至要求/回覆訊息,以便應用程式可以控制這些標頭,請將 ManualAddressing 屬性設定為 true

適用於