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

  • Home
  • SEARCH
  • 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 8964929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:41:56+00:00 2026-06-15T16:41:56+00:00

I have two WinForms applications: a ‘server’ and a ‘client’. On the server private

  • 0

I have two WinForms applications: a ‘server’ and a ‘client’. On the server

private ServiceHost host;
private const string serviceEnd = "Done";

public Form1()
{
    InitializeComponent();
}

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);

    host = new ServiceHost(
        typeof(SqlInfo),
        new Uri[] { new Uri("net.pipe://localhost") });

    host.AddServiceEndpoint(typeof(ISqlListing),
            new NetNamedPipeBinding(),
            serviceEnd);

    host.Open();
}

Where

public class SqlInfo : ISqlListing
{
    public SqlInfo() {}

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

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

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

On the client I have

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

public Form1()
{
    InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
    List<string> l = pipeProxy.PullSql();
    string s = String.Empty;
    foreach (string str in l)
        s += str + " ";
    this.richTextBoxSql.AppendText(s.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();
}

The problem is, that when I ‘pull’ the List<string> from the server using pipeProxy.PullSql() it is calling the public SqlInfo() {} default constructor and setting the sqlList = null.

How do I get this code to return the text in the RichTextBox on the server app?

  • 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-15T16:41:57+00:00Added an answer on June 15, 2026 at 4:41 pm

    This is because you are using this kind of service host:

     host = new ServiceHost(
            typeof(SqlInfo),
            new Uri[] { new Uri("net.pipe://localhost") });
    

    you are passing a type and the WCF framework guess it have to create an instance of type SqlInfo to handle the request. Try to pass a reference to your constructed SqlInfo instance, ie sqlInfo in your case.
    Use this overload of ServiceHost, it allow tyou to pass the instance directly:

    host = new ServiceHost(
                sqlInfo,
                new Uri[] { new Uri("net.pipe://localhost") });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two separate .NET applications, one server and another WinForms. WinForms app has
I have two files client.php and server.php. The client file send a HTTP request
We have a couple of winforms applications that host a bunch of icons in
I have two different WinForms applications, AppA & AppB. Both are running .NET 2.0.
I have two applications, a WinForms app and a Windows Service that will both
I have two WinForms applications and I need to add text to TextBox in
I have made a simple test application for the issue, two winforms each containing
In Winforms you can have two controls tied to the same datasource in a
I have a winforms app that initially displays a window with two file dialog
* I have two winform applications coded in C# each on different applications. And

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.