Mike
8/17/2004 1:52:00 AM
I'd like to have the first-running application that references my object
host a singleton server for the app's lifetime, and I'd like the hosting
application to use a local (non-remoted, same process) version of the
object.
For instance, if my winforms app is the first app to need the object, it
will do a registerWellKnownServerType on a singleton that is also used
locally, and if an IIS application on the same machine runs first, I'll
create a the local object and cache it in the ASP.Net Application object and
then register it. Otherwise, if one or the other is running, it will use a
remoted version. Is it possible to have this
local-and-remoted-access-to-the-same-singleton scenario work? (With
appropriate lock()'s in case the local and remote context threads muck with
state at the same time.)
The impetus is that I'd like a management console to be able to run w/o IIS
active, but most of the time I want the IIS application to host the object
and have fast, local access to it. In the case that I run one or more
managment consoles from local or remote machines with IIS already hosting
the object, they will connect to the already running object.
One problem is .Net's choice of implicit remote creating via new() which I
don't really like. It seems like before a registerWellKnownClientType "new
foo(...)" means one thing, and after the registration it means something
else - an explict Remote.Create( typeof(foo), ...) seems cleaner. Once
rWKCT is called, how do I create local, non-remote, non-singlton versions of
the object if I wanted to?
I guess in the case where the hosting app exits, it would cause an exception
on the client, or I could have the process stick around while there are
still non-timed-out clients (unless IIS gets aggressive with an ostensibly
zombified process.)
thanks,
mike