Click here to Skip to main content
12,621,228 members (34,892 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
I created a program in a Server - Client manner using .NET and .NET.Sockets with twoo projects.
In a Server project I have a Form which has a button and all I want is to Click in that button and open a form in Client project.
If I have only one project it goes like this:
private void buttonOpenForm_Click(object sender, EventArgs e)
 Form2 frmForm2 = new Form2();

Is there a way that I can open a Form2 (Client side) form Form1 (Server side).

Thank you in advance form your reply.
Posted 25-Jan-13 6:58am
Sergey Alexandrovich Kryukov 25-Jan-13 12:02pm
Other "project"? Even the question makes no sense.

If you mean "other assembly", it could be possible.

Talking about client-server, you need to explain what do you mean, exactly. It might make some sense, only remotely :-)

dr_iton 26-Jan-13 5:00am
I meaned how to open forms from different namespaces.
I created a program from twoo namespaces, in second namespace I have 4 forms which ones somehow using .Net and .Net.Sockets need to communicate with one form in first namespace.
P.S. The data of namespace2 forms are stored in three text files inside namespace1.
One more question: If I press debug, the form from namespace one is not Showing. How to fix it.
Thank you in advance for your reply.
Namespaces means nothing. It's just naming. There is no such thing as "from namespace". You can open anything from any namespace, with no limitation.

Probably, you need to know how to create and reference assemblies. Then, you can use anything from other assemblies in exact same way as the same assembly, but only public declarations.

And namespaces are irrelevant: any assembly may declare any number of namespaces, two different assemblies declare the same assembly...

Logi Guna 25-Jan-13 12:16pm
let "Client Side" open form2 by itself, then "Server Side" can give notification to "Client Side" to open form2. if this what you want, it still possible.
dr_iton 25-Jan-13 12:37pm
That is what I'm trying to do.
Is there a way to make that hapen.
I'm still learning c# programming and I'm courious to know that if its possible or not.
Other question in this project is, I used text files to store the data, I have to store them in Server side of programm. Client side of programm it needs those data to fill the form using Sockets. I know how to get the data from Server to Clent in Console Application, but I don't know how to do that in Windows Form Application in net framework 3.5.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I assume you have Form1 as main form in "Client Side".

Code for Form1 "Client Side"
private void Form1_Load(object sender, EventArgs e)
    System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.ShowForm2));
private void ShowForm2(object state)
    var hWait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset, "Global\\Form2Show");
    while (true){
        hWait.WaitOne(); // Waiting signal from ServerSide
        Form2 f = new Form2();
        this.Invoke(new System.Threading.ThreadStart(f.Show));

Code for "Server Side" (when button pressed)
// Notify Client Side
private void buttonOpenForm_Click(object sender, EventArgs e)

EDIT: according to OP reply "Other question in this project is, I used text files to store the data, I have to store them in Server side of programm. Client side of programm it needs those data to fill the form using Sockets."

Have a look here.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100