WCF内部异常消息"URI'net.tcp://..."的注册已存在."尝试通过WCF服务支持双LAN时 [英] WCF inner exception message "A registration already exists for URI 'net.tcp://....' " when trying to support a dual LAN from a WCF service
问题描述
我有一个自托管的WCF服务,该服务使用net.tcp协议作为终结点,并且在具有普通LAN卡的PC上运行良好.
I have a self-hosted WCF service which is using the net.tcp protocol for an endpoint and it works fine on a PC with a normal LAN card.
但是,我想支持具有双LAN卡的PC,这给我带来了问题.我为两张卡分配了不同的IP地址(192.168.1.1和193.168.1.1).然后,我更改了app.config文件以尝试通过使用第二个IP地址为WCF服务添加第二个终结点来支持双LAN. (我的WCF客户端可以处理选择使用两个端点地址中的哪一个.)
However, I want to support PCs which have dual LAN cards and this gives me problems. I have assigned different IP addresses to the two cards (192.168.1.1 and 193.168.1.1). I then changed my app.config file to try to support the dual LAN by adding a second endpoint for the WCF service, using the second IP address. (My WCF client can handle selecting which of the two endpoint addresses to use.)
运行服务时,出现以下错误消息:
When I run the service, I get the following error message:
"net.tcp://193.168.1.1:59301/MyClientService"中具有合同"IMyClientService"的ChannelDispatcher无法打开其IChannelListener.
The ChannelDispatcher at 'net.tcp://193.168.1.1:59301/MyClientService' with contract(s) "'IMyClientService'" is unable to open its IChannelListener.
内部异常的其他信息: URI'net.tcp://193.168.1.1:59301/MyClientService'已经存在注册.
Additional information from inner exception: A registration already exists for URI 'net.tcp://193.168.1.1:59301/MyClientService'.
注意:如果我更改了app.config文件中第二个端点上的端口号(例如,如果我使用193.168.1.1:59302),则该服务可以正常启动.这是一种解决方法,但是如果可能的话,能够为两个LAN使用相同的端口将很有用.
Note: If I change the port # on the second endpoint in the app.config file (e.g. if i use 193.168.1.1:59302), the service starts up fine. That's a workaround, but it would be useful to be able to use the same port for both LANs, if possible.
哦,我尝试在绑定上使用portSharingEnabled(运行Net.TCP端口共享服务),但这没有帮助.
Oh, and I tried portSharingEnabled on the binding (with the Net.TCP Port Sharing Service running) but that didn't help.
预先感谢...
我的app.config文件如下:
My app.config file looks like this:
<!-- Information about assembly binding and garbage collection -->
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
<system.serviceModel>
<services>
<service name ="MyNamespace.MyClientService" behaviorConfiguration="MyServiceBehavior">
<host>
<baseAddresses>
<!-- Using TCP -->
<add baseAddress = "net.tcp://localhost:59301/MyClientService/" />
</baseAddresses>
</host>
<!-- Using TCP -->
<endpoint
address="net.tcp://192.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<endpoint
address="net.tcp://193.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<bindings>
<!-- ==================================================================================== -->
<!-- TCP/IP bindings -->
<netTcpBinding>
<binding name="NetTcpBinding_IMyClientService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<!-- <serviceMetadata httpGetEnabled="True"/> -->
<serviceMetadata/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
推荐答案
"localhost"解析为什么?
What does "localhost" resolve to?
好像您要在"localhost"上添加一个基本地址,并添加两个附加端点,其中一个端点可能与localhost冲突.
Looks like you're adding a base address on "localhost" and two additional endpoints, one of which will probably conflict with localhost.
尝试删除基址,看看是否有区别...
Try removing the base address, see if that makes a difference...
这篇关于WCF内部异常消息"URI'net.tcp://..."的注册已存在."尝试通过WCF服务支持双LAN时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!