【发布时间】:2011-02-15 09:44:48
【问题描述】:
我创建了一个 ComVisible 程序集以用于经典 asp 应用程序。该程序集应充当 wcf 客户端,并使用命名管道连接到同一台机器上的 wcf 服务主机(在 Windows 服务内)。 wcf 服务主机可以与其他客户端正常工作,因此问题一定出在此程序集中。
为了让事情顺利进行,我添加了对 ComVisible 程序集和代理类的服务引用,并为我生成了相应的 app.config 设置。到目前为止一切都很好,除了在 asp 代码中使用我的程序集执行 CreateObject 时无法识别应用程序配置。
我尝试对 Binding 和 Endpoint 进行硬编码(仅用于测试),并使用以下代码将这两个传递给我的 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() 时?或者当您在绑定上设置属性时?
标签: .net wcf configuration wcf-binding wcf-client