Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / October 2003

Tip: Looking for answers? Try searching our database.

it seems easy,but i can not do it...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Yang - 31 Oct 2003 03:27 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.