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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:36:40+00:00 2026-06-15T13:36:40+00:00

All, I have extended this tutorial to get and reverse string displayed in two

  • 0

All, I have extended this tutorial to get and reverse string displayed in two seperate WinForm applications. However, the end goal is to get this working between to WinForm apps that pass SQL between eachother. To facilitate this I have extended this example and the following is what I have

A library .dll containing

public class WcfInterface
{
    private static WcfInterface instance;
    private ServiceHost host;
    private const string serviceEnd = "Done";

    protected WcfInterface()
    {
    }

    public static WcfInterface Instance()
    {
        if (instance == null)
            instance = new WcfInterface();
        return instance;
    }

    public void OpenServiceHost<T, U>() 
    {
        host = new ServiceHost(typeof(U), new Uri[] { new Uri("net.pipe://localhost") });
        host.AddServiceEndpoint(typeof(T), new NetNamedPipeBinding(), serviceEnd);
        host.Open();
    }

    public void CloseServiceHost<T>()
    {
        host.Close();
    }

    public T AddListnerToServiceHost<T>()
    {
        ChannelFactory<T> pipeFactory = 
            new ChannelFactory<T>(new NetNamedPipeBinding(), 
                                         new EndpointAddress(String.Format("net.pipe://localhost/{0}", 
                                                                                      serviceEnd)));
        T pipeProxy = pipeFactory.CreateChannel();
        return pipeProxy;
    }
}

So on the ‘server’ form, I do

private void Form1_Load(object sender, EventArgs e)
{
    List<string> sqlList = new List<string>();
    foreach (string line in this.richTextBoxSql.Lines)
        sqlList.Add(line);
    SqlInfo sqlInfo = new SqlInfo(sqlList);
    WcfInterface wcfInterface = WcfInterface.Instance();
    wcfInterface.OpenServiceHost<ISqlListing, SqlInfo>();
}

Where

public class SqlInfo : ISqlListing
{
    private List<string> sqlList;
    public SqlInfo(List<string> sqlList)
    {
        this.sqlList = sqlList;
    }

    public List<string> PullSql()
    {
        return sqlList;
    }
}

[ServiceContract]
public interface ISqlListing
{
    [OperationContract]
    List<string> PullSql();
}

In the client WinForm app

private ISqlListing pipeProxy;
public Form1()
{
    InitializeComponent();
    WcfInterface wcfInterface = WcfInterface.Instance();
    pipeProxy = wcfInterface.AddListnerToServiceHost<ISqlListing>();
}

and on the click event I attampt to get the List<string> from the server

private void button1_Click(object sender, EventArgs e)
{
    this.richTextBoxSql.Text = pipeProxy.PullSql().ToString(); // Code hangs here.
}

My question is what is wrong with this?

Thanks for your time.


Edit. I have now also changed the client code according to comments as follows

private ISqlListing pipeProxy { get; set; }
private const string serviceEnd = "Done";

public Form1()
{
    InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
    this.richTextBoxSql.Text = pipeProxy.PullSql().ToString(); 
 }

private void Form1_Load(object sender, EventArgs e)
{
    ChannelFactory<ISqlListing> pipeFactory =
    new ChannelFactory<ISqlListing>(
      new NetNamedPipeBinding(),
      new EndpointAddress(
         String.Format("net.pipe://localhost/{0}", serviceEnd)));

    pipeProxy = pipeFactory.CreateChannel();
}

this also hangs on the click event.

  • 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-06-15T13:36:41+00:00Added an answer on June 15, 2026 at 1:36 pm

    The way you have the code set up, you are creating a WCF server on the client by referencing WcfInterface.Instance. You are then calling it from the same thread that it is being served on, causing your application to lock up.

    There are a number of ways to get around this. Here are a few that come to mind:

    • Get the service running in your first WinForm app, then use the “Add Service Reference” functionality in visual studio to create your proxies. Note that you’ll have to
    • You can still reference a common library for the WCF contracts, but rework your code so that you’re not creating an instance of the service in your “client” WinForms app.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get all declared classes which are have extended another parent class.
I have an application developed to get all the third party applications installed and
I have a form[method=get] which has a number of checkboxes all have the same
I have extended NLog to log all items in the Exception.Data collection. So, when
I am using CodeIgniter and have extended CI_Model . so all my models now
I have extended a RelativeLayout with all its constructor.And I have created a layout
I have extended org.eclipse.ui.editors.text.TextEditor to implement a custom editor. For this editor, I have
I have extended DotNetOpenAuth ASP.NET MVC Login sample while trying to get at least
I'm following this tutorial (http://lightbird.net/dbe/cal1.html) to build a calendar app, but I can't get
I have extended LinearLayout (vertical) to create a custom compound component. This in turn

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.