[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Re: How do i create an object that can be activated remotely and local

Allen Anderson

7/6/2004 2:43:00 PM

use proxies for the business object. When you don't want the remote
version, instantiate the implementation class, when you want the
remote version, use the createinstance and the abstract class. I
wrote an article on abstract CAO classes here that might be helpful in
implementation.

http://www.glacialcomp.../ArticleDetail.aspx?articleI...

Cheers,
Allen Anderson
http://www.glacialcomp...
mailto: allen@put my website base here.com


On Tue, 6 Jul 2004 06:47:02 -0700, "E.Lucas"
<E.Lucas@discussions.microsoft.com> wrote:

>I have a BusinessObject class which inherits from ContextBoundObject.
>
>Sometimes I'm createing BusinessObject CAO instance on a remote server and that works well. (I use Activator.CreateInstance(...,...,{uri})
>
>The problem is: When I create a local instance from my BusinessObject, it also is wrapped in a TransparentProxy. (That happens if I use the "new BusinessObject" syntax, or the Activator.CreateInstance(type,args[]) syntax).
>
>Question: How can I create a local instance of my BusinessObject class without the TransparentProxy wrapper ? (and still be able to create CAO instances from this class)
>
>Thanks !

1 Answer

Allen Anderson

7/7/2004 2:36:00 PM

0

the fact that the local object also carries the abstract class with
it shouldn''t matter at all. It''s not a transparent proxy object.
It''s just an abstract class that the current class inherited from so
your not taking any proxy baggage along with it when you instance it
locally with a simple new CAOClass();

Cheers,
Allen Anderson
http://www.glacialcomp...
mailto: allen@put my website base here.com

On Wed, 7 Jul 2004 04:36:02 -0700, "E.Lucas"
<ELucas@discussions.microsoft.com> wrote:

>Hi Allen,
>
>Thanks for your reply.
>
>I''ve tested your solution and found out that the problem continues.
>The object returned by your SAOCAOClassFactory inherits from a class which inherits from MarshalByRef, so even if I instantiate this object locally (using by instance:
>
>//Class definitions
>class CAOClassDef : MarshalByRefObject { ... }
>class CAOClass : CAOClassDef {...}
>...
>//Client code
>CAOClass obj = new CAOClass();
>
>In this case, obj is wrapped in a TransparentProxy. How do I avoid that ?
>
>You can check this behavior by puting a breakpoint on a line after the object instantiation and trying to call any method from this object on the debugger Command window. It will tell you that <error: cannot evaluate field of a proxy object>
>
>Do you have a solution for instantiating CAOClass as a real local object (i.e. not wrapped in a TransparentProxy) ?
>
>Thanks again :)
>
>"Allen Anderson" wrote:
>
>> use proxies for the business object. When you don''t want the remote
>> version, instantiate the implementation class, when you want the
>> remote version, use the createinstance and the abstract class. I
>> wrote an article on abstract CAO classes here that might be helpful in
>> implementation.
>>
>> http://www.glacialcomp.../ArticleDetail.aspx?articleID=CAOGuide
>>
>> Cheers,
>> Allen Anderson
>> http://www.glacialcomp...
>> mailto: allen@put my website base here.com
>>
>>
>> On Tue, 6 Jul 2004 06:47:02 -0700, "E.Lucas"
>> <E.Lucas@discussions.microsoft.com> wrote:
>>
>> >I have a BusinessObject class which inherits from ContextBoundObject.
>> >
>> >Sometimes I''m createing BusinessObject CAO instance on a remote server and that works well. (I use Activator.CreateInstance(...,...,{uri})
>> >
>> >The problem is: When I create a local instance from my BusinessObject, it also is wrapped in a TransparentProxy. (That happens if I use the "new BusinessObject" syntax, or the Activator.CreateInstance(type,args[]) syntax).
>> >
>> >Question: How can I create a local instance of my BusinessObject class without the TransparentProxy wrapper ? (and still be able to create CAO instances from this class)
>> >
>> >Thanks !
>>
>>