Re: What about CAO?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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??




.



Relevant Pages

  • Re: What about CAO?
    ... So if I have the remoting service set as SingleCall - it's ... it's not possible to instantiate a new ... Now implement this interface on the ... > only on the client). ...
    (microsoft.public.dotnet.framework.remoting)
  • Please explain remoting and delegates
    ... And for every project I always defined an interface between the client ... and the server, the implementation resided in the CAO assembly on the server. ...
    (microsoft.public.dotnet.general)
  • RE: Instantiating CAO without using new operator
    ... This method can be used to create the instance of CAO using interface. ... > interfaces also ensure clean seperation between client and server. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Instantiating CAO without using new operator
    ... This method can be used to create the instance of CAO using interface. ... > interfaces also ensure clean seperation between client and server. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: What doesnt lend itself to OO?
    ... >>server is a pure data transfer interface. ... essentially exposing the client or service implementation. ... >>paradigms can be abstracted just like any other problem space in an OO ...
    (comp.object)