MessageQueue.EncryptionRequired 属性


获取或设置一个指示队列是否只接受非私有(非加密)消息的值。Gets or sets a value that indicates whether the queue accepts only non-private (non-encrypted) messages.

 property System::Messaging::EncryptionRequired EncryptionRequired { System::Messaging::EncryptionRequired get(); void set(System::Messaging::EncryptionRequired value); };
public System.Messaging.EncryptionRequired EncryptionRequired { get; set; }
member this.EncryptionRequired : System.Messaging.EncryptionRequired with get, set
Public Property EncryptionRequired As EncryptionRequired


EncryptionRequired 值之一。One of the EncryptionRequired values. 默认值为 NoneThe default is None.



访问“消息队列”方法时出错。An error occurred when accessing a Message Queuing method.


下面的代码示例获取并设置消息队列的 EncryptionRequired 属性的值。The following code example gets and sets the value of a message queue's EncryptionRequired property.

// Set the queue's EncryptionRequired property value.
queue.EncryptionRequired = System.Messaging.EncryptionRequired.Optional;

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


当你指定发送到队列的消息需要加密时,只会加密消息正文。When you specify that encryption is required for the messages sent to a queue, only the message bodies are encrypted. 不能对其他成员(例如 LabelSenderId 属性)进行加密。The other members (for example, the Label and SenderId properties) cannot be encrypted.

设置此属性将修改 "消息队列" 队列。Setting this property modifies the Message Queuing queue. 因此,任何其他 MessageQueue 实例都受此更改的影响。Therefore, any other MessageQueue instances are affected by the change.

加密消息会使消息成为私有消息。Encrypting a message makes the message private. 您可以通过适当地设置 EncryptionRequired 属性来指定要 NoneBodyOptional 的队列的加密要求。You can specify the queue's encryption requirement to be None, Body, or Optional by setting the EncryptionRequired property appropriately. 消息的 UseEncryption 设置必须与队列的加密要求相对应。The UseEncryption setting of the message must correspond to the encryption requirement of the queue. 如果未对消息进行加密,但队列指定了 Body,或者如果消息已加密但队列指定 None,则队列将拒绝该消息。If the message is not encrypted but the queue specifies Body, or if the message is encrypted but the queue specifies None, the message is rejected by the queue. 如果发送应用程序在此事件中请求否定确认消息,则消息队列将指示消息对发送应用程序的拒绝。If the sending application requests a negative acknowledgment message in this event, Message Queuing indicates the message's rejection to the sending application. 如果 trueUseDeadLetterQueue 属性,则会将加密失败的消息发送到死信队列。If the UseDeadLetterQueue property is true, a message that fails encryption is sent to the dead-letter queue. 否则,消息将丢失。Otherwise, the message is lost.

下表显示了此属性在各种工作组模式下是否可用。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 NoNo
远程计算机和直接格式名称Remote computer and direct format name NoNo