This works? Wow! How does remoting know that the MyCAO object is a CAO?
Don't I have to define that somewhere?
The difference between an SAO and a CAO is the manner in which the client
obtains the proxy for the object. An SAO is an object for which the client
can generate its own proxy without additional info from the server. To do
this, the client must know the exact URL at which the remote object lives,
i.e. the object must be "well-known". When you call Activator.GetObject()
and pass a URL to it, you are creating an SAO reference since the client has
all the info it requires to communicate with the remote object.
The proxy for a CAO requires additional info from the server in order to
know how to communicate with the specific object instance. This info comes
in the form of an ObjRef passed from the server to the client which contains
the information such as the remote object's URI. If you didn't obtain your
reference to the remote object via a well-known address, then the only way
you'll be able to communicate with it is through an ObjRef, which means it's
a CAO.
The main hurdle to understaning this is realizing that SAO/CAO is not a
property of the class or even the object instance but a property of the
reference you hold to the object. For example, it's possible to hold both a
CAO reference and an SAO reference to the exact same object on the server.
If I setup the SAOFactory as SingleCall SAO then will the MyCAO object still
exist once the SAO call has completed?
Absolutely. The lifetime of the returned object has nothing to do with the
lifetime of the object that instantiated it. This is just as true with
remoting as it is in non-remoting contexts. The lifetime of the object (from
the perspective of the client) will be determined solely by its lifetime
lease. This is the same regardless of whether the object is a remoted as a
CAO or SAO.
Ken