MessageQueue.MachineName 屬性

定義

取得或設定訊息佇列位置的電腦名稱。

public:
 property System::String ^ MachineName { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Messaging.MessagingDescription("MQ_MachineName")]
public string MachineName { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Messaging.MessagingDescription("MQ_MachineName")>]
member this.MachineName : string with get, set
Public Property MachineName As String

屬性值

佇列位置的電腦名稱。 訊息佇列預設是 ".",也就是本機電腦。

屬性

例外狀況

MachineNamenull。 -或-

電腦的名稱無效,可能是因為語法不正確。

存取訊息佇列方法時發生錯誤。

範例

下列程式代碼範例會取得並設定消息佇列 MachineName 屬性的值。

// Set the queue's MachineName property value to the name of the local
// computer.
queue.MachineName = ".";

// Display the new value of the queue's MachineName property.
Console.WriteLine("MessageQueue.MachineName: {0}", queue.MachineName);

備註

MachineName是佇列Path易記名稱語法的一個整數位元件。 下表顯示當您想要使用其易記名稱來識別佇列路徑時,應該用於指定類型的佇列語法。

佇列類型 語法
公用佇列 MachineName\QueueName
私用佇列 MachineName\Private$\QueueName
記錄檔佇列 MachineName\QueueName\Journal$
計算機日誌佇列 MachineName\Journal$
機器寄不出的信件佇列 MachineName\Deadletter$
計算機交易寄不出的信件佇列 MachineName\XactDeadletter$

指定 MachineName時,請使用 “.” 做為本機計算機。 只有電腦名稱可辨識這個屬性,例如 。 Server0 屬性 MachineName 不支援IP位址格式。

如果您根據 MachineName定義 Path ,則應用程式會在離線工作時擲回例外狀況,因為需要域控制器進行路徑轉譯。 因此,在離線工作時,您必須針對 Path 語法使用 FormatName

MachineNamePathQueueName 屬性是相關的。 變更 MachineName 屬性會導致 Path 屬性變更。 它會從新的 MachineNameQueueName建置。 例如,將 (變更 Path 為使用格式名稱語法,) 重 MachineName 設 和 QueueName 屬性以參考新的佇列。 如果 屬性是空的QueueName,則會Path設定為您所指定計算機的 日誌 佇列。

下表顯示此屬性是否可在各種工作組模式中使用。

工作組模式 可用
本機電腦
本機計算機和直接格式名稱
遠端電腦
遠端電腦和直接格式名稱

適用於

另請參閱