Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3272348
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:49:00+00:00 2026-05-17T18:49:00+00:00

Im building a WPF 3.5 desktop app that has a self-hosted WCF service. The

  • 0

Im building a WPF 3.5 desktop app that has a self-hosted WCF service.

The service has an PollingDuplexHttpBinding endpoint defined like so:

public static void StartService()
    {
        var selfHost = new ServiceHost(Singleton, new Uri("http://localhost:1155/"));

        selfHost.AddServiceEndpoint(
            typeof(IMyService), 
            new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll) {ReceiveTimeout = new TimeSpan(1,0,0,0)},
            "MyService"
        );

        ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
        smb.HttpGetEnabled = true;
        selfHost.Description.Behaviors.Add(smb);

        selfHost.AddServiceEndpoint(typeof(IPolicyRetriever), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());

        selfHost.Open();
    }

Note: the IPolicyRetriever is a service that enables me to define a policy file

This works and I can see my service in my client Silverlight application. I then create a reference to the proxy in the Silverlight code like so:

        EndpointAddress address = new EndpointAddress("http://localhost:1155/MyService");

        PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll);
        binding.ReceiveTimeout = new TimeSpan(1, 0, 0, 0);
        _proxy = new MyServiceClient(binding, address);
        _proxy.ReceiveReceived += MessageFromServer;
        _proxy.OrderAsync("Test", 4);

And this also works fine, the communication works!

But if I leave it alone (i.e. dont sent messages from the server) for longer than 1 minute, then try to send a message to the client from the WPF server application, I get timeout errors like so:

The IOutputChannel timed out attempting to send after 00:01:00. Increase the timeout value passed to the call to Send or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

Its all running on localhost and there really should not be a delay, let alone a 1 minute delay. I dont know why, but the channel seems to be closed or lost or something…

I have also tried removing the timeouts on the bindings and I get errors like this

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted

How can I try to find out whats wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:49:00+00:00Added an answer on May 17, 2026 at 6:49 pm

    WPF uses wsDualHttpBinding, Silverlight – Polling Duplex.
    WPF solution is simple; Silverlight requires ServiceHostFactory and a bit more code. Also, Silverlight Server never sends messages, rather Client polls the server and retrieves its messages.

    After many problems with PollingDuplexHttpBinding I have decided to use CustomBinding without MultipleMessagesPerPoll.

    web.config

    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="SlApp.Web.DuplexServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    
        <services>
            <service behaviorConfiguration="SlApp.Web.DuplexServiceBehavior" name="SlApp.Web.DuplexService">
                <endpoint address="WS" binding="wsDualHttpBinding" contract="SlApp.Web.DuplexService" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>      
    </system.serviceModel>
    

    DuplexService.svc:

    <%@ ServiceHost Language="C#" Debug="true" Service="SlApp.Web.DuplexService" Factory="SlApp.Web.DuplexServiceHostFactory" %>
    

    DuplexServiceHostFactory.cs:

        public class DuplexServiceHostFactory : ServiceHostFactoryBase
        {
            public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
            {
                return new DuplexServiceHost(baseAddresses);
            }
        }
    
        class DuplexServiceHost : ServiceHost
        {
            public DuplexServiceHost(params Uri[] addresses)
            {
                base.InitializeDescription(typeof(DuplexService), new UriSchemeKeyedCollection(addresses));
            }
    
            protected override void InitializeRuntime()
            {
                PollingDuplexBindingElement pdbe = new PollingDuplexBindingElement()
                {
                    ServerPollTimeout = TimeSpan.FromSeconds(3),
                    //Duration to wait before the channel is closed due to inactivity
                    InactivityTimeout = TimeSpan.FromHours(24)
                };
    
                this.AddServiceEndpoint(typeof(DuplexService),
                    new CustomBinding(
                        pdbe,
                        new BinaryMessageEncodingBindingElement(),
                        new HttpTransportBindingElement()), string.Empty);
    
                base.InitializeRuntime();
            }
        }
    

    Silverlight client code:

    address = new EndpointAddress("http://localhost:43000/DuplexService.svc");
    binding = new CustomBinding(
                new PollingDuplexBindingElement(),
                new BinaryMessageEncodingBindingElement(),
                new HttpTransportBindingElement()
            );
    proxy = new DuplexServiceClient(binding, address);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a small wpf app in C#. When a button gets clicked
Background - If I am building a WPF desktop application (VS2010 & .NET 4)
I'd like ask a question about building applications in .NET that use data from
I'm building an application in C# using WPF. How can I bind to some
Building on what has been written in SO question Best Singleton Implementation In Java
Im building a web application which is a process management app. Several different employee
I'm considering writing a cross-platform desktop app, initially for Mac/Windows, but eventually for Linux
I am developing a small desktop application in VB.NET. It has to be formal
Building on How Do You Express Binary Literals in Python , I was thinking
Building a client-side swing application what should be notified on a bus (application-wide message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.