[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Windows Form + .NET Remoting problem

yihcheng

11/4/2004 4:50:00 AM

Hi all,

I write a client-server proram.
Client is a windows form app and it will invoke some methods in server-side
component by .net remoting (httpchannel and singleton mode).
Server-side is a windows form too composed 2 parts. Form1.cs is the Windows
form part. program.cs is the .net remoting component part.
client will invoke server-side remoting component and get some information
back.

My problem is that how I show the client-invoked information on the Form1.cs
object textbox ?
For example, program.cs has a method called namereg. The client will invoke
this method and put
the client name into an arraylist. How can I put the client name fom
program.cs namereg method to Form1.cs object textbox control ?

you can download the program code at http://wse.myftp.or...

Please help,
Thank you very much
Bruce



1 Answer

Ken Kolda

11/4/2004 4:16:00 PM

0

This question seems to be getting asked a lot recently. The easiest way to
do this is as follows:

1) In your Form1 class, create a static instance of your Form1 form.
2) Replace the "new Form1()" call in the Application.Run() to use the static
instance.
3) From your remoted object, simply access the class through the static
variable.

Here's an example:

// Code for your main Windows form
public class Form1 : System.Windows.Forms
{
public static readonly Form1 MainForm = new Form1();

public static void Main()
{
Application.Run(MainForm);
}

public void SetName(string name)
{
if (this.InvokeRequired)
this.Invoke(new somedelegate(SetName), new object[] { name });
else
this.txtClientName.Text = name;
}
}

// In your server object, just invoke the main form, e.g.
public void namereg(string name)
{
Form1.MainForm.SetName(name);
}

Hope that helps -
Ken

"yihcheng" <bruceyclee@yahoo.com> wrote in message
news:%23qzmCniwEHA.1400@TK2MSFTNGP11.phx.gbl...
> Hi all,
>
> I write a client-server proram.
> Client is a windows form app and it will invoke some methods in
server-side
> component by .net remoting (httpchannel and singleton mode).
> Server-side is a windows form too composed 2 parts. Form1.cs is the
Windows
> form part. program.cs is the .net remoting component part.
> client will invoke server-side remoting component and get some information
> back.
>
> My problem is that how I show the client-invoked information on the
Form1.cs
> object textbox ?
> For example, program.cs has a method called namereg. The client will
invoke
> this method and put
> the client name into an arraylist. How can I put the client name fom
> program.cs namereg method to Form1.cs object textbox control ?
>
> you can download the program code at http://wse.myftp.or...
>
> Please help,
> Thank you very much
> Bruce
>
>
>