日期:2014-05-20  浏览次数:20944 次

没有名称为“calculatorServiceBehavior”的服务行为。什么意思?
没有名称为“calculatorServiceBehavior”的服务行为。我在研究WCF这个东西

        private void btnStart_Click(object sender, EventArgs e)
        {
            host = new ServiceHost( typeof(WcfService1.Service1) );
            host.Open();
            label1.Text = "订票服务已启动";
        }



以下是app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service
        name="WcfService1.Service1"
        behaviorConfiguration="calculatorServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/"/>
          </baseAddresses>
        </host>
        <endpoint address="" 
                  binding="wsHttpBinding" 
                  contract="WcfService1.IService1"/>  
      </service>
    </services>
    
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

------解决方案--------------------
behaviorConfiguration="calculatorServiceBehavior"
<behavior name="CalculatorServiceBehavior">

不知道是不是这个原因的