简体   繁体   中英

Hosting nettcp WCF service in IIS7 fails

Ok, so I have a really simple WCF service that I would like to host under IIS. I have enabled the "Windows Communication Foundation Non-Http Activation" so that is not the problem. I am running IIS 7,5 on a Windows 7 computer with .NET 4.0 installed. My web.config looks like this:

<?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>

The service is hosted as an application called "NetTcpServiceTest" under the default web site in IIS. When I try to add a reference to net.tcp://localhost/NetTcpServiceTest/MySuperService.svc/mextcp in visual studio I get the following error:

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.

And the error in the event log is:

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: .

I have also enabled the binding for the site and application. Does anyone know how to solve this? When I search for it on internet the only answer I found was to re-install IIS and .NET, but that doesn't sounds like a real solution for me.

如果您在.NET之后安装了IIS,请尝试使用aspnet_regiis.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM