MessageQueue.MachineName 屬性


取得或設定訊息佇列位置的電腦名稱。Gets or sets the name of the computer where the Message Queuing queue is located.

 property System::String ^ MachineName { System::String ^ get(); void set(System::String ^ value); };
public string MachineName { get; set; }
member this.MachineName : string with get, set
Public Property MachineName As String



佇列位置的電腦名稱。The name of the computer where the queue is located. 訊息佇列預設是 ".",也就是本機電腦。The Message Queuing default is ".", the local computer.



MachineNamenullThe MachineName is null.

電腦的名稱無效,可能是因為語法不正確。The name of the computer is not valid, possibly because the syntax is incorrect.

存取訊息佇列方法時發生錯誤。An error occurred when accessing a Message Queuing method.


下列程式碼範例會取得並設定訊息佇列之屬性的值 MachineNameThe following code example gets and sets the value of a message queue's MachineName property.

// 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是佇列易記名稱語法的整陣列件 PathThe MachineName is an integral component of the friendly name syntax of the queue Path. 下表說明當您想要使用易記名稱來識別佇列路徑時,您應該針對指定類型的佇列使用的語法。The following table shows the syntax you should use for a queue of a specified type when you want to identify the queue path using its friendly name.

佇列類型Queue type 語法Syntax
公用佇列Public queue MachineName\QueueName
私用佇列Private queue MachineName\Private$\QueueName
記錄檔佇列Journal queue MachineName\QueueName\Journal$
電腦日誌佇列Machine journal queue MachineName\Journal$
電腦寄不出的信件佇列Machine dead-letter queue MachineName\Deadletter$
電腦交易式寄不出的信件佇列Machine transactional dead-letter queue MachineName\XactDeadletter$

指定時,請使用 "." 作為本機電腦 MachineNameUse "." for the local computer when specifying the MachineName. 這個屬性只會辨識出電腦名稱稱,例如 Server0Only the computer name is recognized for this property, for example, Server0. MachineName屬性不支援 IP 位址格式。The MachineName property does not support the IP address format.

如果您 Path 在中定義,則在 MachineName 離線工作時,應用程式會擲回例外狀況,因為路徑轉譯需要網域控制站。If you define the Path in terms of the MachineName, the application throws an exception when working offline because the domain controller is required for path translation. 因此,在離線工作時,您必須使用做 FormatNamePath 語法。Therefore, you must use the FormatName for the Path syntax when working offline.

MachineNamePathQueueName 屬性是相關的。The MachineName, Path, and QueueName properties are related. 變更 MachineName 屬性會導致 Path 屬性變更。Changing the MachineName property causes the Path property to change. 它是從新的 MachineName 和所建立 QueueNameIt is built from the new MachineName and the QueueName. 變更 Path (例如,若要使用格式名稱語法) 重設 MachineName 和屬性, QueueName 以參考新的佇列。Changing the Path (for example, to use the format name syntax) resets the MachineName and QueueName properties to refer to the new queue. 如果 QueueName 屬性是空的,則 Path 會設定為您所指定電腦的日誌佇列。If the QueueName property is empty, the Path is set to the Journal queue of the computer you specify.

下表顯示此屬性是否適用于各種工作組模式。The following table shows whether this property is available in various Workgroup modes.

工作組模式Workgroup mode 可用Available
本機電腦Local computer Yes
本機電腦和直接格式名稱Local computer and direct format name Yes
遠端電腦Remote computer Yes
遠端電腦和直接格式名稱Remote computer and direct format name No