C# svc工作,但配置文件不工作

C# svc工作,但配置文件不工作,c#,wcf,.net-4.0,C#,Wcf,.net 4.0,我试图使用配置文件来定义端点和服务信息。我有一个非常简单的代码,其中包含单向服务和双工服务。当我没有尝试更改配置文件时,单向方法就起作用了 现在,我想使用配置文件来定义这两个服务 Service1合同名称为IOneWayService,Service2合同名称为ICallBackService 它们都在各自的具体类nameOneWayService.svc.cs和CallBackService.svc.cs中实现了代码 此时的配置文件如下所示: <configuration>

我试图使用配置文件来定义端点和服务信息。我有一个非常简单的代码,其中包含单向服务和双工服务。当我没有尝试更改配置文件时,单向方法就起作用了

现在,我想使用配置文件来定义这两个服务

Service1合同名称为
IOneWayService
,Service2合同名称为
ICallBackService

它们都在各自的具体类name
OneWayService.svc.cs
CallBackService.svc.cs
中实现了代码

此时的配置文件如下所示:

<configuration>
   <system.web>
      <compilation debug="true" targetFramework="4.0" />
   </system.web>
   <system.serviceModel>
      <serviceHostingEnvironment  multipleSiteBindingsEnabled="true">
         <serviceActivations>
            <add relativeAddress="OneWayService.svc" service="TestingWcf.OneWayService"/>
            <add relativeAddress="CallBackService.svc" service="TestingWcf.CallBackService"/>
         </serviceActivations>
      </serviceHostingEnvironment>
      <services>
         <service name="TestingWcf.OneWayService">
            <endpoint address="http://localhost:60847/One"
              binding="wsHttpBinding"
              contract="IOneWayService" />
         </service>
         <service name="TestingWcf.CallBackService">
            <endpoint address="http://localhost:60847/Two"
               binding="wsHttpBinding"
               contract="IDuplexService" />
         </service>
      </services>
      <behaviors>
         <serviceBehaviors>
            <behavior>
               <serviceMetadata httpGetEnabled="true"/>
               <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
         </serviceBehaviors>
      </behaviors>
   </system.serviceModel>
   <system.webServer>
      <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
</configuration>

当我试图通过此url执行OneWayService时,总是出现此错误:
http://localhost:60847/OneWayService.svc

合同名称“IOneWayService” 在列表中找不到 该处执行的合同 “单向服务”

有人知道为什么吗

编辑 我已从
服务主机环境
标记中删除了
multipleSiteBindingsEnabled=true
,并在合同中添加了名称空间,我可以运行OneWay服务

此外,双工不能绑定到
wsHttpBinding
。我不得不把它改成
NetTcpBinding
。但是,双工还有一个错误:

配置绑定扩展 'system.serviceModel/bindings/NetTcpBinding' 找不到。验证此 绑定扩展是正确的 注册于 system.serviceModel/extensions/bindingExtensions 而且拼写正确

从这一点上说,我又迷路了

编辑2 我在绑定名称中出错。我有一个大写字母表示NetTcpBinding,它需要小写:
NetTcpBinding
。但是,它仍然不起作用,现在我有:

协议“net.tcp”不可用 支持。>。<


好的,这就解释了-VisualStudio默认使用内置的Cassini web服务器(除非您已经切换到使用)-并且该服务器只支持普通http

卡西尼不支持net.tcp之类的东西

您需要开始使用一个单独的IIS虚拟目录,并首先启用所有必要的支持内容(在“添加/删除Windows功能”对话框中)

您是在IIS中托管此功能(哪个版本??),还是在自托管(例如,在Windows NT服务中)??