GeneralCalculatorService.svc代码:
<%@ ServiceHost Language="C#" Debug="true" Service="Services.GeneralCalculatorService" %>web.config配置:
<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="calculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="Services.GeneralCalculatorService" behaviorConfiguration="calculatorServiceBehavior">
        <endpoint binding="basicHttpBinding" contract="Contracts.ServiceContract.IGeneralCalculator"/>
      </service>
    </services>
  </system.serviceModel>
  <system.web>
    <compilation targetFramework="4.0">
      <assemblies>
        <add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
</configuration>
代码入上,在.net4.0中,运行http://localhost/WCFServices/GeneralCalculatorService.svc ,
报错:
The type 'Services.GeneralCalculatorService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.请各位指教,非常感谢!!!

解决方案 »

  1.   

    类型'Services.GeneralCalculatorService',因为在提供的ServiceHost指令,服务属性值或在配置元素的system.serviceModel提供/ serviceHostingEnvironment /找不到serviceActivations。
      

  2.   

    <service name="Services.GeneralCalculatorService" behaviorConfiguration="calculatorServiceBehavior">
            <endpoint binding="basicHttpBinding" contract="Contracts.ServiceContract.IGeneralCalculator"/>
          </service>
    name="Services.GeneralCalculatorService"
    没识别到这个
      

  3.   

    namespace Services
    {
        public class GeneralCalculatorService : IGeneralCalculator
        {
            public double Add(double x, double y)
            {
                return x + y;
            }
        }
    }上面是服务类定义,请高人指教,该如何做才能运行成功!!!