-1

我正在使用 wcf 服务向我的客户提供一些数据来绘制图表。我已经看到了一些东西并创建了服务但是当我运行它时显示以下错误。如何克服它? The type 'WcfService2.Servi', provided as the Service attribute value in theServiceHost directive, or provided in the configuration elementsystem.serviceModel/serviceHostingEnvironment/serviceActivations could not be found

这是我的 web.config 文件

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>

    <services>

      <service name="WcfService2.Servi" behaviorConfiguration="WcfService1.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="webHttpBinding" contract="WcfService2.Servi" behaviorConfiguration="web" bindingConfiguration="crossDomain">

          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">
          <!-- 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>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>

      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="crossDomain" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>

    </bindings>

  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
4

1 回答 1

0

您的服务合同类型称为WcfService2.Servi。这看起来像一个错字。如果您更正此问题,该服务是否有效?

于 2013-11-05T10:18:57.920 回答