• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Need help in Microsoft's Remote Object application

Hi,

I am working on a sample application of Remote Object. It works
if I don't have parameters passed in calling the object, i.e., client
can talk to the server. But how to pass a parameter to server's
object? Below is part of the source code in the server:

public static int Main(string [] args) {

.....

RemotingConfiguration.RegisterWellKnownServiceType(

typeof(SampleObject), "mysample", WellKnownObjectMode.SingleCall );

.....

Basically I want to pass args into SampleObject, how do I do it?

Thanks for any help.

Jennifer

}
0
jfz2004
Asked:
jfz2004
  • 2
  • 2
1 Solution
 
sumixCommented:
With server activation you can only use default constructors (no parameters) for remote objects. You can use methods of the remote object to pass values to it.

If you have constructors that receive parameters you may use client activation (create instances of the remote object with Activator.CreateInstance instead of RegisterWellKnownServiceType) but you should be aware of the details of this approach

See http://msdn2.microsoft.com/en-us/library/y0h540a7(VS.80).aspx 
0
 
jfz2004Author Commented:
Thanks,

How to use methods of the remote object to pass value?

Below is the source code for my object:

public class SampleObject : MarshalByRefObject
{
public static DataTable vTable = new DataTable("vTable");

public string getVTable(string date, int id)
{
}
}

0
 
sumixCommented:

In your first post you showed the server part of the application, the one that creates the instance.
The client who uses this remote object will have a piece of code to register the type, then you will create an instance and call its methods like with any other class:

        ChannelServices.RegisterChannel(new TcpChannel());
        RemotingConfiguration.RegisterWellKnownClientType(
                                                           typeof(SampleObject),
                                                           "tcp://localhost:portNr/AppName/mysample");

        SampleObject  obj = new SampleObject();
        obj.getVTable(date,id);
...

 you need here the port number (portNr) used for server activation and ApplicationName specified on the server
0
 
jfz2004Author Commented:
This is similar to what I am doing. Thanks.
I will try it over the weekend.
Jennifer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now