Re: Remoting and Robotics
- From: "Padu" <padu@xxxxxxxxxxxx>
- Date: Fri, 7 Jul 2006 16:44:17 -0700
I've just finished my first remoting "hello world" app. Instead of using
console apps, I've created windows forms for both host and client apps. I'm
not sure I've completely understood the concept though.
Following the help file "how to", I've created a remotable type that
inherits from MarshalByRefObj, and has only one method:
public class RemotableType: MarshalByRefObject
{
public string HelloWorld()
{
return "Hello World";
}
}
I've compiled it into RemotableType.dll
Then I've created the host app in a windows form:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RemotingConfiguration.Configure(@"RemotingHost.exe.config.xml",false);
}
}
The config.xml I've copied from C# help. It is defined as a wellknown
singleton, uses http on port 8989.
Finally the client windows form app has two buttons, a "connect" (now I
understand that it doesnt connect really) and a "Get Hello World":
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private RemotableType remoteObject;
private void button2_Click(object sender, EventArgs e)
{
label1.Text = remoteObject.HelloWorld();
}
private void button1_Click(object sender, EventArgs e)
{
RemotingConfiguration.Configure(@"RemotingClient.exe.config.xml",
false);
remoteObject = new RemotableType();
}
}
It all works, both on the same machine or in different machines.
Now, let's say I add a text box to the host application main form. What do I
have to do to add a method that retrieves the value of that text box from
the client app? I know I'll have to add another method to my RemotableType,
but I'm not sure how the dll will access the host windows form app. I
suspect I'm incurring in a major concept flaw here.
Cheers
Padu
.
- References:
- Remoting and Robotics
- From: Padu
- Remoting and Robotics
- Prev by Date: Re: How does "new" work in a loop?
- Next by Date: Re: How does "new" work in a loop?
- Previous by thread: Re: Remoting and Robotics
- Next by thread: replacing strange characters pulled from db field
- Index(es):
Loading