首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> 關於.NET

WCF 分散式開發常見錯誤 (19):MSMQ 佇列開啟失敗 —— 安全模式與 ExactlyOnce 設定

     編輯:關於.NET

托管宿主 WCF MSMQ 服務啟動時報錯:「There was an error opening the queue. Ensure that MSMQ is installed and running...」。核心原因在於預設 NetMsmqBinding 安全模式與 ExactlyOnce 特性與環境不符。

修正程式碼配置

var queBinding = new NetMsmqBinding(NetMsmqSecurityMode.None);
queBinding.ExactlyOnce = false;
queBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;

host.AddServiceEndpoint(typeof(IWCFMSMQService), queBinding, queBaseAddress);
if (host.State != CommunicationState.Opening) host.Open();

三個關鍵點

  1. NetMsmqSecurityMode.None:關閉傳輸/訊息層安全,適合內網測試或已有傳輸層加密環境;
  2. ExactlyOnce = false:關閉「僅一次投遞」保證,避免需 MSMQ Active Directory 整合的交易式佇列需求;
  3. 以程式碼而非設定檔建立端點,確保設定生效,避免設定檔殘留衝突。

參考討論

MSDN 論壇討論串 確認修改安全模式即可解決。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved