MessageQueue.GetMachineId(String) 方法

定义

获取计算机的标识符,此 MessageQueue 引用的队列位于该计算机上。

public:
 static Guid GetMachineId(System::String ^ machineName);
public static Guid GetMachineId (string machineName);
static member GetMachineId : string -> Guid
Public Shared Function GetMachineId (machineName As String) As Guid

参数

machineName
String

包含队列的计算机的名称,名称前不含两个反斜杠 (\\)。

返回

Guid

Guid,表示队列所在的计算机的唯一标识符。

例外

未能检索到计算机标识符,可能是因为目录服务不可用,例如当正在脱机工作时。

  • 或 -

访问“消息队列”方法时出错。

示例

下面的代码示例调用 GetMachineId(String)

// Get the name of the computer that contains the queue.
string machineName = queue.MachineName;

// Display the return value of the MessageQueue.GetMachineId method.
Console.WriteLine("MessageQueue.GetMachineId(): {0}",
    MessageQueue.GetMachineId(machineName));

注解

可以将计算机的标识符用于两个目的,等等:读取计算机日记并设置安全证书。 但是,脱机工作时无法调用 GetMachineId(String) 远程计算机,因为应用程序必须有权访问域控制器上的目录服务。

计算机标识符 (或计算机标识符) 是 Guid 将计算机添加到企业时创建的消息队列。 消息队列将计算机标识符与关键字Journal组合在一起Machine,以创建具有语法Machine=<computeridentifier>;Journal的计算机日记格式名称。 计算机日志(也称为日记队列)是一个系统队列,用于在属性为trueUseJournalQueue存储应用程序生成的消息的副本。

仅当构造队列的格式名称时,日志的此语法才有效。 路径名称语法为 MachineName\Journal$.

下表显示了此方法是否在各种工作组模式下可用。

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

适用于

另请参阅