Re: What about CAO?
- From: Helge Lenuweit <""nospam\"@nospam@xxxxxxxxxxxx">
- Date: Thu, 11 Aug 2005 10:57:43 +0200
Hi,
using an interface-only approach, it's not possible to instantiate a new CAO object on the client side - you can't just use "new MyObject(...)" because the implementation is only available on the server.
One possible solution to this is to extend your shared assembly with an interface for a SAO object. It needs a single method which returns a new instance of the CAO, like GetCAO(). Now implement this interface on the server and expose the object. Then get a reference of this object on the client via GetObject (you do not instantiate the object, you get a proxy of the existing one from the server - so it will work with the interface only on the client).
Now that you have the SAO instance on the client, call its method that returns the CAO. Make sure to appropriately take care of lifetime issues and this object will retain state.
Regards, Helge
RCS schrieb:
So have a successful remoting environment setup with a shared assembly that stores the interfaces-only that are available. The client has a copy, and the remoting server has that, and also has objects that are offerred, that implement those interfaces.
On the client, I am using Activator.GetObject() to create the object, but it's not keeping state. To be more specific, I'll set properties, and they don't keep. It's as if every call is a new call to the server.
So it looks like from everything I've read, that I should be instantiating these objects different, as CAO - but I can't seem to find the syntax for this. For example, here is my function for creating an object:
Private Function GetRemotingObject(Of typ)() As typ
Dim InterfaceName As String = GetType(typ).ToString()
Dim intLastPos As Int16 = InterfaceName.LastIndexOf(".")
If intLastPos > 0 Then
InterfaceName = InterfaceName.Substring(intLastPos + 1, (InterfaceName.Length - intLastPos) - 1)
End If
Return CType(Activator.GetObject( _
GetType(typ), _
"http://" + WEBSERVER + "/WASRemoting/" + InterfaceName + ".rem") _
, typ)
End Function
Sorry for the VB, but the front-end needed to be that way, because I'm whipping up examples for other duh-velopers. So how else could I instantiate this object via remoting to make it CAO, and ideally - keep state??
.
- Follow-Ups:
- Re: What about CAO?
- From: RCS
- Re: What about CAO?
- References:
- What about CAO?
- From: RCS
- What about CAO?
- Prev by Date: Problem in 3-Tier Architecture
- Next by Date: Re: Calling events on the server
- Previous by thread: What about CAO?
- Next by thread: Re: What about CAO?
- Index(es):
Relevant Pages
|