Re: remoting client form, reference to object
From: Ken Kolda (ken.kolda_at_elliemae-nospamplease.com)
Date: 01/11/05
- Next message: MrDotNet: "Re: Host remote object in IIS but Security problem"
- Previous message: Ken Kolda: "Re: Remoting with SSL"
- In reply to: dotnettester via DotNetMonster.com: "remoting client form, reference to object"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 Jan 2005 08:49:47 -0800
Double-check to make sure your MainForm_Load event handler is attached to
the Load event on the form, i.e. in the InitializeComponent() function there
should be a line reading:
this.Load += new EventHandler(MainForm_Load);
Also try putting a break point in the MainForm_Load method to be sure it's
being called before the button click event.
That said, a better place to put the RemotingConfiguration.Configure() call
is in your Main() function prior to Application.Run() -- that will ensure
remoting is configured before anything else happens.
Ken
"dotnettester via DotNetMonster.com" <forum@DotNetMonster.com> wrote in
message news:7756bc8600cf4ef0bbe9269243d2f7d3@DotNetMonster.com...
>
> I posted this on some other discssion boards w/o any reply. I am a C
programmer in the past, did VB6/DCOM/COM+ a lot, but interested trying to to
move to .NET, C# and remoting. So if this question is to "newbie" please
forgive me and give me a hint where to look for the anwers. (book/website
etc..). I haven't seen C# examples of Windows Application clients with
remoting that do something on a button click.
>
> Many thanks in advance!
>
> Service is an instance of remote object. VB works fine. in C# get a
exception "Object reference not set to an instance of an object". How the C#
button_click code can get a reference to the instantiated service object? I
just want the create the service object once. Looked hours and hours on the
web for a remoting example in C# using Windows forms, no where to find.
Desperate....
>
> VB#
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
> RemotingConfiguration.Configure("Client.exe.config")
> service = New ServiceClass
> End Sub
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
> TextBox1.Text = vbCrLf + "ConsoleIdentity: " +
WindowsIdentity.GetCurrent().Name
> TextBox1.Text = TextBox1.Text + vbCrLf + "The server says : " +
service.GetServerString
> TextBox1.Text = TextBox1.Text + vbCrLf + "Server time is: " +
service.GetServerTime
> End Sub
>
> C#
> public class MainForm : System.Windows.Forms.Form
> {
> ServiceClass service;
> /// other code omitted.... just show you service is declared here.
> }
> private void MainForm_Load (object sender, System.EventArgs e)
> {
> // if we move following code to Click event code then it works fine
> RemotingConfiguration.Configure("Client.exe.config");
> service = new ServiceClass();
> }
> private void ButtonCall_Click(object sender, System.EventArgs e)
> {
> textBox1.Text = "\r\nConsoleIdentity: " +
WindowsIdentity.GetCurrent().Name;
> // The exection happens here:
> textBox1.Text = textBox1.Text + "\r\nThe server says : " +
service.GetServerString();
> textBox1.Text = textBox1.Text + "\r\nServer time is: " +
service.GetServerTime();
> }
>
> --
> Message posted via http://www.dotnetmonster.com
- Next message: MrDotNet: "Re: Host remote object in IIS but Security problem"
- Previous message: Ken Kolda: "Re: Remoting with SSL"
- In reply to: dotnettester via DotNetMonster.com: "remoting client form, reference to object"
- Messages sorted by: [ date ] [ thread ]