Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've created a service using this link :http://arcanecode.com/2007/05/22/windows-services-in-c-getting-started-part-2/[^]

I configure my config for https, but cannot start my service. I get this error

"Service cannot be started. System.InvalidOperationException: Contract requires Session, but Binding 'WSHttpBinding' doesn't support it or isn't configured properly to support it."

1.
XML
<service name="Service.MyService" behaviorConfiguration="MyServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:443/MyService"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyServiceEndpoint" contract="IMyService"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>


2.
XML
<wsHttpBinding>
    <binding name="MyServiceEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="8192" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
    </binding>
</wsHttpBinding>


3.
XML
<serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>


Can anybody help me? What else I should do for starting it?

Thanks all
Posted
Updated 14-Oct-13 2:04am
v2

Try adding the following attributes to your Service class which implements IMyService.

eg:
C#
[ServiceContract(SessionMode=SessionMode.Required)]
public interface IMyService
{

}

 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
 public class MyService: IMyService
 {
 . 
 .
 }

you can change the Instance context mode on your choice read here[^] for more
 
Share this answer
 
Comments
AshLiGaLa 15-Oct-13 10:04am    
I have that attributes. But that doesnot help in my case
Thanks Jibesh,
tried what you suggested but it didn't work. However I since discovered that BasicHttpBinding does not support PerSession. Once I changed the binding to WsHttpBinding it worked correctly.

thanks for your input

regards
Pat
 
Share this answer
 
Comments
CHill60 16-Mar-15 4:16am    
If you want to respond to a post use the Have a Question or comment link, otherwise the poster will not be notified

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900