Remote object with arguments?

  • Thread starter Thread starter mkadlec99
  • Start date Start date
M

mkadlec99

Got a remoting question I was hoping someone could solve. I have an
object (UpdateFlifo) that
has two constructors, one empty, and one with arguments. I want to
expose this
object remotely, which I have done in the code below and everything
works fine.
I now want to expose this object using constructor arguements, but not
sure
how to do this, do you have any idea?


RemotingConfiguration.RegisterWellKnownServiceType (
typeof(UpdateFlifo),
"UpdateFlifo",
WellKnownObjectMode.Singleton);


Mark.
 
Hi Mark,

Server-activated objects require a default constructor.

"Server Activation" (.NET Remoting)
http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconServerActivation.asp

If you must use a constructor on the client then you'll need a
client-activated object. Singleton, however, is not client-activated.

"Client Activation" (.NET Remoting)
http://msdn.microsoft.com/library/d...ide/html/cpconclientactivation.asp?frame=true

It's also possible to use dynamic publication by marshaling the object
yourself. This way you can use any constructor that you'd like when you
create the object on the server. The object becomes registered as a
Singleton, for all intensive purposes. Dynamic publication and the
application configuration file are mutually exclusive methods for registering
a Singleton. Dynamic publication is another form of server-activation:

"RemotingServices.Marshal"
http://msdn2.microsoft.com/en-us/library/b6fy37a8.aspx
 
Glad you explained it, no wonder I couldn't find any info on the Server
activated constructor. I might try your suggestion of Marshalling
myself. Thanks,

Mark.
 
Dave,

Ok, I ran into a problem. I coded your recommendation for
marshalling myself using the RemotingServices.Marshal command, but
worked only for a while. Everything seemed to be working, but after 5
- 10 calls, I get a remotingerror unhandled exception in mscorlib.dll.

I suspect this is some sort of memory/threading issue, is this a risk
of using the Marshal command on my server?

Mark.
 
Hi Mark,

I've used dynamic publication and haven't run into any indeterministic
problems like that. Behind the scenes I assume that the marshaled object
becomes a singleton, in the same way as when an object is registered through
configuration to be a singleton. There aren't any memory/threading concerns
that you should have (AFAIK) when calling Marshal that you shouldn't have
anyway when using configuration, so I'd be concerned more with your particular
implementation.

What is the exception?
(message and stack would be nice)

When is the exception thrown? (e.g., is it thrown at the client when calling
a method on the remote object?)

Is the failing remote method doing anything that is related to remoting
configuration?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top