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友好名称语法的组成部分。 下表显示了在想要使用其友好名称标识队列路径时,应用于指定类型的队列的语法。

队列类型 Syntax
公共队列 MachineName\QueueName
专用队列 MachineName\Private$\QueueName
日记队列 MachineName\QueueName\Journal$
计算机日志队列 MachineName\Journal$
计算机死信队列 MachineName\Deadletter$
计算机事务死信队列 MachineName\XactDeadletter$

指定 .. 时 MachineName,对本地计算机使用“.”。 仅识别此属性的计算机名称,例如 Server0。 该 MachineName 属性不支持 IP 地址格式。

如果根据条件Path定义MachineName,应用程序会在脱机工作时引发异常,因为需要域控制器进行路径转换。 因此,脱机工作时必须使用 FormatName 语法 Path

MachineName属性PathQueueName属性相关。 更改 MachineName 属性会导致 Path 属性发生更改。 它是从新的 MachineNameQueueName. 更改 Path (例如,若要使用格式名称语法),将 MachineName 重置属性 QueueName 以引用新队列。 QueueName如果该属性为空,则Path设置为指定的计算机的“日记”队列。

下表显示了此属性是否可用于各种工作组模式。

工作组模式 可用的
本地计算机
本地计算机和直接格式名称
远程计算机
远程计算机和直接格式名称

适用于

另请参阅