就建了个wcf的项目测试了一下  顺便把interface和cs分开了一下 把interface放到了独立的类库
   结果在浏览这个svc时就报错啦      这是怎么回事呢

解决方案 »

  1.   

    添加引用了吗?另外web.config里边的ServiceModel的节点里边要配置contract的~
      

  2.   

    web.config里边的ServiceModel的节点里边要配置contract
      

  3.   

    <?xml version="1.0"?>
    <configuration>  <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <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" aspNetCompatibilityEnabled="True"/>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer></configuration>这是web.config里面滴
      

  4.   

    .................... 好像不需要改web.config  都是自动生成滴啊
      

  5.   

    LZ还是多看看wcf基础的资料吧
      

  6.   

      把cs放到了app_data中  interface放到了独立的类库中  并对svc进行了修改 
     <%@ ServiceHost Language="C#" Debug="true" Service="trs.wcf.test.wcf_user" CodeBehind="user.cs" %>
      
       
      

  7.   

      修改了web.config <?xml version="1.0"?>
    <configuration>  <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.serviceModel>
        <services>
          <service name="trs.wcf.Method.IUser" behaviorConfiguration="CalculatorServiceBehavior">
            <endpoint address="" binding="wsHttpBinding" contract="trs.wcf.Method.IUser">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="CalculatorServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer></configuration>
      

  8.   

       如果不做任何处理  也就是说不去人为的分开svc,cs,interface 运行就不抱错
        但是我现在想把它们分开  这样就会更清晰明了些   
        请给位有心人事支招  先谢啦!