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 7555175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:32:10+00:00 2026-05-30T11:32:10+00:00

Could you please tell me why duplex communication with TcpTransportBindingElement doesn’t work in my

  • 0

Could you please tell me why duplex communication with TcpTransportBindingElement doesn’t work in my Metro application ?

According to this document Metro subset of .Net Framework supports TCP binding.

So I wrote WCF server as console application. Here is source code:

static void Main()
{
    UiWcfSession.OnInitialize += ClientInitialize;

    var baseAddresses = new Uri("net.tcp://localhost:9000/");

    var host = new ServiceHost(typeof(UiWcfSession), baseAddresses);

    var reliableSession = new ReliableSessionBindingElement { Ordered = true, InactivityTimeout = TimeSpan.MaxValue };
    var binding =
        new CustomBinding(reliableSession, new TcpTransportBindingElement()) { ReceiveTimeout = TimeSpan.MaxValue };

    host.AddServiceEndpoint(typeof(IClientFulfillmentPipeService), binding, "");

    var metadataBehavior = new ServiceMetadataBehavior();
    host.Description.Behaviors.Add(metadataBehavior);
    var mexBinding = MetadataExchangeBindings.CreateMexTcpBinding();
    host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex");

    host.Open();

    Thread.CurrentThread.Join();
}

private static void ClientInitialize(int uiprocessid, string key)
{
    Debug.WriteLine("ClientInitialize");
}

and here is client code in Metro app:

partial class MainPage
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void onclick(object sender, RoutedEventArgs e)
    {
        try
        {
            var ep = new EndpointAddress("net.tcp://localhost:9000/");
            var binding = new CustomBinding(new TcpTransportBindingElement());
            var ctx = new InstanceContext(new Wrapper());
            var pipeFactory = new DuplexChannelFactory<IClientFulfillmentPipeService>(ctx, binding, ep);
            IClientFulfillmentPipeService commChannel = pipeFactory.CreateChannel();

            // open up the the comm channel with a reasonable timeout...
            ((IChannel)commChannel).Open();

            commChannel.Initialize(1234, "Test");

            ((IChannel)commChannel).Close();
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }
}

So it kinda works. But when I walk step by step in the debugger in Metro app it hangs and never returns from the function commChannel.Initialize.

Why is it happening ? What am I missing ?

  • 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-30T11:32:11+00:00Added an answer on May 30, 2026 at 11:32 am

    Turns out I can’t use synchronous client in Metro. I have to use asynchronous calls. That’s why it didn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

could please anybody tell me what is wrong with this regexp ? ((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\\:([0-9]{2,5}) for
Could someone please tell me whats wrong with this code because I cannot find
Could anyone please tell me why this happens, $a = 0.000022 echo $a //
I've recently written this with help from SO. Now could someone please tell me
could anyone please tell me what is wrong this this code? I get a
Could you please tell me, what happens in this script: $conn = fsockopen($server, 43);
Could someone please tell me if this is possible in C or C++? void
could somebody please tell me why this code fails. url is nil after calling
Could you please tell me how this web site managed to do this? http://weblopedi.net/
Could someone please tell me what is wrong with this code? It works fine

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.