In the following remoting codes,I want to use the client to use method
Getaaa() to get aaa's value in Form1,then how can I implement public int
Getaaa()?
this is the server part:
namespace DZ
{
public class Form1 : System.Windows.Forms.Form
{
public int aaa;
private System.ComponentModel.Container components = null;
public Form1()
{
aaa=1;
InitializeComponent();
TcpServerChannel channel=new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(A),"Hi",WellKnownO
bjectMode.Singletone);
}
......
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
public class A:System.MarshalByRefObject
{
public int Getaaa()
{
//the client use this method to get aaa's value.How can I implement this
method?
}
}
}
this is the client part:
namespace Client
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
ChannelServices.RegisterChannel(new TcpClientChannel());
A obj=(A)Activator.GetObject(typeof(A),"tcp://localhost:8086/Hi");
if(obj==null)
{
Console.WriteLine("could not locate server");
Console.ReadLine();
return;
}
int value=obj.Getaaa();
Console.ReadLine();
}
}
}
reguards,
Jeff Yang
Sunny - 31 Oct 2003 16:01 GMT
Hi Jeff,
if you'll have only one instance of the form, why don't you make aaa
public static?
than from Getaaa() you can get the value with Form1.aaa.
Sunny
> In the following remoting codes,I want to use the client to use method
> Getaaa() to get aaa's value in Form1,then how can I implement public int
[quoted text clipped - 62 lines]
> reguards,
> Jeff Yang