我已经查看了这些帖子: wcf System.ServiceModel.AddressAlreadyInUseException, Windows Service hosted WCF over HTTPS, Getting AddressAlreadyInUseException after upgrading to .NET 4.5, 他们都没有解决我的问题。 我在.net 4.5中有几个wcf服务。所有这些都在同一个地址中,我在WCF服务主机中得到了这个例外:
System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL https://+:443/mafawcf01/ServicioAddin.svc/ because TCP port 443 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.DatagramChannelDemuxer`2.OnOuterListenerOpen(ChannelDemuxerFilter filter, IChannelListener listener, TimeSpan timeout)
at System.ServiceModel.Channels.SingletonChannelListener`3.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenAuthenticator.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecurityUtils.OpenTokenAuthenticatorIfRequired(SecurityTokenAuthenticator tokenAuthenticator, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionServerSettings.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecurityListenerSettingsLifetimeManager.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.DelegatingChannelListener`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
System.Net.HttpListenerException (0x80004005): The process cannot access the file because it is being used by another process
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
这是我的app.congif:
<host>
<baseAddresses>
<add baseAddress="https://localhost:443/mafawcf01/ServicioAddin.svc"/>
</baseAddresses>
</host>
</service>
<service name="mafawcf01.ServicioPing" behaviorConfiguration="mafawcf01.ServicioPingBehavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="mafawcf01.IServicioPing">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:443/mafawcf01/ServicioPing.svc" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="mafawcf01.Service1Behavior" name="mafawcf01.ServicioCargue">
<endpoint address="https://localhost:443/MafaWCF01/ServicioCargue.svc"
binding="customBinding" bindingConfiguration="myCustomHttpBinding"
contract="mafawcf01.IServicioCargue" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:443/MafaWCF01/ServicioCargue/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="mafawcf01.Service1Behavior" name="mafawcf01.ServicioValidacionMultiple">
<endpoint address="https://localhost:443/MafaWCF01/ServicioValidacionMultiple.svc"
binding="customBinding" bindingConfiguration="transporteSeguro"
contract="mafawcf01.IServicioValidacionMultiple" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:443/MafaWCF01/ServicioValidacionMultiple/" />
</baseAddresses>
</host>
我已经使用此命令保留了端口:
netsh http add urlacl url=https://+:443/MafaWCF01
还有与该端口关联的证书:
netsh http add sslcert ipport=0.0.0.0:443 certhash={some cert hash} appid={some appid}
您还需要其他信息吗?
答案 0 :(得分:5)
我发现WCF应用程序(或更确切地说http.sys
)可以在关闭后暂停一段时间。如果你试图立即重新启动它,你可以得到可怕的AddressAlreadyInUseException
因为应用程序的前一个实例以某种方式持有它。我发现,如果我等待几分钟再试一次,它可以工作。
答案 1 :(得分:4)
如果这有助于任何人。尝试在控制台应用程序中托管wcf服务时遇到了同样的问题。我所做的是打开wcf服务库的属性(Alt + Enter或右键单击&gt;属性),然后转到属性窗口中的WCF选项选项卡,并在同一解决方案中调试另一个项目时取消选中&#34;启动WCF服务主机#34 ;.问题是解决的。
答案 2 :(得分:0)
我遇到了同样的问题
无法找到任何其他应用程序在该端口上收听,没有任何冲突,但此错误消息并未离开。
它发生在服务崩溃之后,从那以后我再也无法提起服务了
无论如何,PC重启后一切正常。哦,好吧..