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.


下列程式碼範例會取得並設定訊息佇列之屬性的值 EncryptionRequiredThe 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. 您可以藉 None Body OptionalEncryptionRequired 適當地設定屬性,將佇列的加密需求指定為、或。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. 如果 UseDeadLetterQueue 屬性為,則會將 true 加密失敗的訊息傳送到寄不出的信件佇列。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 No
遠端電腦和直接格式名稱Remote computer and direct format name No