我已經創建了一個ComVisible程序集以用於classic-asp應用程序。程序集應該充當wcf客戶端,並使用命名管道連接到同一臺機器上的wcf服務主機(在windows服務中)。 wcf服務主機與其他客戶端正常工作,所以問題必須在此程序集內。WCF:手動配置綁定和端點導致SerciveChannel故障狀態
爲了讓事情起作用,我添加了ComVisible程序集和代理類的服務引用,併爲我生成了相應的app.config設置。一切都很好,除了在使用我的程序集在asp代碼中執行CreateObject時應用程序配置不會被識別。
我去,並試圖硬編碼(只是用於測試),綁定和端點,並使用此代碼通過這兩個我ClientBase派生代理的構造函數:
private NetNamedPipeBinding clientBinding = null;
private EndpointAddress clientAddress = null;
clientBinding = new NetNamedPipeBinding();
clientBinding.OpenTimeout = new TimeSpan(0, 1, 0);
clientBinding.CloseTimeout = new TimeSpan(0, 0, 10);
clientBinding.ReceiveTimeout = new TimeSpan(0, 2, 0);
clientBinding.SendTimeout = new TimeSpan(0, 1, 0);
clientBinding.TransactionFlow = false;
clientBinding.TransferMode = TransferMode.Buffered;
clientBinding.TransactionProtocol = TransactionProtocol.OleTransactions;
clientBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
clientBinding.MaxBufferPoolSize = 524288;
clientBinding.MaxBufferSize = 65536;
clientBinding.MaxConnections = 10;
clientBinding.MaxReceivedMessageSize = 65536;
clientAddress = new EndpointAddress("net.pipe://MyService/");
MyServiceClient client = new MyServiceClient(clientBinding, clientAddress);
client.Open();
// do something with the client
client.Close();
但是,這將導致以下錯誤:
通信對象System.ServiceModel.Channels.ServiceChannel不能用於通信,因爲它處於故障狀態。
環境是.Net Framework 3.5/C#。我在這裏錯過了什麼?
編輯: 我只是想,當使用basicHttpBinding,一切都按預期工作。所以問題只能出現在NetNamedPipeBinding中。
有人嗎?
拋出的錯誤在哪裏?當你打電話給Open()?或者當你在綁定上設置屬性? – Matt 2011-06-19 23:57:25