Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法运行第一个WCF服务_Wcf_.net 4.0 - Fatal编程技术网

无法运行第一个WCF服务

无法运行第一个WCF服务,wcf,.net-4.0,Wcf,.net 4.0,这是我的第一个WCF服务,我收到一个错误: Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata. 代码: Web.Config <?xml version="1.0"?> <configuration> <system.web> <compil

这是我的第一个WCF服务,我收到一个错误:

Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
代码:

Web.Config

    <?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfMathServiceLibrary.MathService">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/WcfMathServiceLibrary/MathService/"/>
          </baseAddresses> 
        </host>
        <endpoint address="" binding="wsHttpBinding" contract="WcfMathServiceLibrary.MathService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" >
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

我不确定是什么问题。你能指导我吗?

我认为你的合同可能需要指向接口,而不是具体的实现

<endpoint address="" binding="wsHttpBinding" contract="WcfMathServiceLibrary.IMath">

我不明白你的意思。我需要在地址中添加任何内容吗?不,只需更改合同以指向接口IMath而不是MathService
<endpoint address="" binding="wsHttpBinding" contract="WcfMathServiceLibrary.IMath">