[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Gaining Access to a Windows App's Forms from its Server Object

Alex Maghen

8/18/2004 11:21:00 PM

I have created a nice little Client-Server test using .Net Remoting. I've
created a separate Interface representing the Remoted (exposed) class from
the Server application. The Server Application is a Windows Application
created in C#.

Everything's working fine with the Client App accessing the ServerClass. But
here's where I get really confused: Let's say I want logic going in inside a
method of my ServerClass to be ablse to access the server application's main
Form or something like that. What I don't understand is, how can my
ServerObject get a reference to the Forms, etc., that make up the running
Windows Server Application?

In my Main(), I'm doing the whole...
RemotingConfiguration.RegisterWellKnownServiceType();
and then I'm doing...
Application.Run(new MainForm);

But now I'm in the loop of the MainForm and calls to my ServerObject don't
know how to GET to my MainForm instance.

Any help will be MUCH appreciated.

Thanks!

Alex


2 Answers

Sam Santiago

8/19/2004 5:20:00 AM

0

Is your remote object a Singleton object? If so, you could save your main
form instance in a variable in your application, instantiate your object
that will be a Singleton, set a property on you object to the form, and
marshal your object to a URI. For example,

myMainForm = new MainForm()
myRemoteInstance = new myObject()
myRemoteInstance.MainFromProp = myMainForm
RemotingServices.Marshal(myRemoteInstance, "objectWellKnownUri")
Application.Run(myMainForm)

Check out the marhal documentation:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeremotingremotingservicesclassmarshal...

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Alex Maghen" <AlexMaghen@discussions.microsoft.com> wrote in message
news:E222D7A9-7B78-44B0-A85B-E545DE39AEF6@microsoft.com...
> I have created a nice little Client-Server test using .Net Remoting. I've
> created a separate Interface representing the Remoted (exposed) class from
> the Server application. The Server Application is a Windows Application
> created in C#.
>
> Everything's working fine with the Client App accessing the ServerClass.
But
> here's where I get really confused: Let's say I want logic going in inside
a
> method of my ServerClass to be ablse to access the server application's
main
> Form or something like that. What I don't understand is, how can my
> ServerObject get a reference to the Forms, etc., that make up the running
> Windows Server Application?
>
> In my Main(), I'm doing the whole...
> RemotingConfiguration.RegisterWellKnownServiceType();
> and then I'm doing...
> Application.Run(new MainForm);
>
> But now I'm in the loop of the MainForm and calls to my ServerObject don't
> know how to GET to my MainForm instance.
>
> Any help will be MUCH appreciated.
>
> Thanks!
>
> Alex
>
>


Nic Gorleer

8/19/2004 1:37:00 PM

0

Add a static member Instance to your MainForm :

public class MainForm
{
internal static MainForm Instance;

static void Main()
{
MainForm.Instance = new MainForm;
Application.Run(MainForm.Instance);
}
}

You can then use MainForm.Instance to access your form from your
ServerClass.

"Alex Maghen" <AlexMaghen@discussions.microsoft.com> wrote in message
news:E222D7A9-7B78-44B0-A85B-E545DE39AEF6@microsoft.com...
> I have created a nice little Client-Server test using .Net Remoting. I've
> created a separate Interface representing the Remoted (exposed) class from
> the Server application. The Server Application is a Windows Application
> created in C#.
>
> Everything's working fine with the Client App accessing the ServerClass.
But
> here's where I get really confused: Let's say I want logic going in inside
a
> method of my ServerClass to be ablse to access the server application's
main
> Form or something like that. What I don't understand is, how can my
> ServerObject get a reference to the Forms, etc., that make up the running
> Windows Server Application?
>
> In my Main(), I'm doing the whole...
> RemotingConfiguration.RegisterWellKnownServiceType();
> and then I'm doing...
> Application.Run(new MainForm);
>
> But now I'm in the loop of the MainForm and calls to my ServerObject don't
> know how to GET to my MainForm instance.
>
> Any help will be MUCH appreciated.
>
> Thanks!
>
> Alex
>
>