locked
How to run in WCF Service Host (WcfSvcHost.exe) mode? RRS feed

  • Question

  • Hello all , i am trying to debug my DataService project not in ASP.NET host mode but like the common WCF service mode, which using WcfSvcHost.exe  to run , but i don't know how to change the app.config is right,  like below:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service behaviorConfiguration="ABCService.Service1Behavior"
            name="ABCService.DataPortal">
            <endpoint address="" binding="wsHttpBinding" contract="System.Data.Services.IRequestHandler">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/Design_Time_Addresses/ABCService/DataPortal/" />
              </baseAddresses>
            </host>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ABCService.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>
        </behaviors>
      </system.serviceModel>
    </configuration>



    i had change the DataContract type to System.Data.Services.IRequestHandler( i am using Data Service  1.5 CTP), but when the WcfSvcHost runing, it said the error:

    System.InvalidOperationException: The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.
       at System.ServiceModel.Dispatcher.OperationFormatter.Validate(OperationDescription operation, Boolean isRpc, Boolean isEncoded)
       at System.ServiceModel.Dispatcher.OperationFormatter..ctor(OperationDescription description, Boolean isRpc, Boolean isEncoded)
       at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter..ctor(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory)
       at System.ServiceModel.Description.DataContractSerializerOperationBehavior.GetFormatter(OperationDescription operation, Boolean& formatRequest, Boolean& formatReply, Boolean isProxy)
       at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch)
       at System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch)
       at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
       at System.ServiceModel.ServiceHostBase.InitializeRuntime()
       at System.ServiceModel.ServiceHostBase.OnBeginOpen()
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open()
       at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)


    Thanks for giving any help :)
    Monday, July 13, 2009 7:04 AM

Answers

  • I found out what it was! It seems there are two IRequestHandler interfaces in the .NET framework. My service was implementing one while in the web.config I was referring to the other one as the contract type. Making sure both were equal (same namespace) fixed the problem!
    MCTS in Web Application Development in .NET 2.0
    Saturday, August 8, 2009 9:42 AM

All replies

  • Did you solve this? I'm running into the same thing.
    MCTS in Web Application Development in .NET 2.0
    Tuesday, August 4, 2009 10:45 AM
  • no, not yet. i think may be decomplie the  WcfSvcHost can find the problem.
    Saturday, August 8, 2009 3:23 AM
  • I found out what it was! It seems there are two IRequestHandler interfaces in the .NET framework. My service was implementing one while in the web.config I was referring to the other one as the contract type. Making sure both were equal (same namespace) fixed the problem!
    MCTS in Web Application Development in .NET 2.0
    Saturday, August 8, 2009 9:42 AM
  • thanks for share your answer, thanks very much!
    Saturday, August 8, 2009 10:10 AM
  • No problem, would you please mark my post as the answer if this works for you? Thanks!


    MCTS in Web Application Development in .NET 2.0
    Sunday, August 9, 2009 4:45 PM