好的,所以我有一个非常简单的WCF服务,我想在IIS下托管。我启用了“Windows Communication Foundation非Http激活”,这不是问题所在。我在安装了.NET 4.0的Windows 7计算机上运行IIS 7,5。我的web.config看起来像这样:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="FirstWcfService.Service" behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="netTcpBinding" contract="NetTcpServiceTest.IMySuperService"
bindingConfiguration="tcpbinding"/>
<endpoint address="mextcp" binding="mexTcpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false
and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- 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>
<bindings>
<netTcpBinding>
<binding name="tcpbinding" portSharingEnabled="true">
<!--<security mode="None"></security>-->
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
<binding name="mexTcpBinding" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
该服务作为IIS中默认网站下名为“NetTcpServiceTest”的应用程序托管。当我尝试在visual studio中添加对net.tcp://localhost/NetTcpServiceTest/MySuperService.svc/mextcp的引用时,出现以下错误:
Metadata contains a reference that cannot be resolved: 'net.tcp://localhost/NetTcpServiceTest/MySuperService.svc/mextcp'.
The message could not be dispatched because the service at the endpoint address 'net.tcp://localhost/NetTcpServiceTest/MySuperService.svc/mextcp' is unavailable for the protocol of the address.
If the service is defined in the current solution, try building the solution and adding the service reference again.
事件日志中的错误是:
An error occurred while trying to listen for the URL '/LM/W3SVC/1/ROOT/NetTcpServiceTest'. This worker process will be terminated.
Sender Information: net.tcp
Exception: System.ServiceModel.WasHosting.TcpAppDomainProtocolHandler/65824025
Process Name: System.ServiceModel.CommunicationException: The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: .
我还启用了网站和应用程序的绑定。有谁知道如何解决这个问题?当我在互联网上搜索它时,我找到的唯一答案是重新安装IIS和.NET,但这对我来说听起来不是真正的解决方案。
答案 0 :(得分:0)
如果您在.NET之后安装了IIS,请尝试aspnet_regiis.exe
。