gpt4 book ai didi

c# - WCF 4 和 NetTcpBinding

转载 作者:太空宇宙 更新时间:2023-11-03 17:45:46 24 4
gpt4 key购买 nike

我正在测试 WCF 4 的无配置功能。<​​/p>

我构建了一个简单的服务并将其部署到 IIS。服务部署为svc文件

客户端配置为空:

<configuration>
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>
</configuration>

Web 服务器上的配置是:

<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

这段代码工作正常:

BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("http://localhost/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);

这段代码不会:

NetTcpBinding myBinding = new NetTcpBinding();
EndpointAddress myEndpoint = new EndpointAddress("net.tcp://localhost:808/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);

我得到的错误是:

Could not connect to net.tcp://localhost/Service1.svc. The connection attempt lasted for a time span of 00:00:02.1041204. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.

默认网站上设置了 net.tcp 绑定(bind)。

我觉得我缺少一些简单的东西。有人有什么想法吗?

最佳答案

我感觉您的 Net.Tcp 端口共享服务 没有启用。

关于c# - WCF 4 和 NetTcpBinding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4805355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com