[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

How to use Marshal By Value

Henke

8/31/2004 9:21:00 AM

Hi!
What actions do I have to do in order to get my objects marshaled by value?
For the moment we are using Marshal by reference, so all my object derive
from MarshalByRef.

Thanks in advance!
/Henke
3 Answers

Robert Jordan

8/31/2004 10:58:00 AM

0

Henke wrote:

> Hi!
> What actions do I have to do in order to get my objects marshaled by value?
> For the moment we are using Marshal by reference, so all my object derive
> from MarshalByRef.

Classes must be serializable to be able to transport them by value.

Bye
Rob

Robert Jordan

8/31/2004 12:24:00 PM

0

Hi,

> I have tried to mark them with:
> [Serializable]
>
> but when I try to connect to the object I get this exception:
> An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
> occurred in mscorlib.dll
> Additional information: Trying to create a proxy to an unbound type.

probably because one of the fields of the classes you declared
[Serializable] is not serializable (because its type is
not declared [Serializable]).

try using this settings in your App.config. you'll get
the exact exception instead the generic
System.Runtime.Remoting.RemotingException:

<configuration>
<system.runtime.remoting>
<customErrors mode="off" />
</system.runtime.remoting>
</configuration>


> If I derive the object from MarshalByRef everything works fine, except that
> I get a reference instead of the object :)

Well, it is much easier to get an object marshaled by ref
then by value. the reason: marshal by value expects
that the whole object graph of a certain object is serializable,
because the remoting infrastructure has to transfer a copy
of the data over the wire.

bye
Rob


>
> "Robert Jordan" wrote:
>
>
>>Henke wrote:
>>
>>
>>>Hi!
>>>What actions do I have to do in order to get my objects marshaled by value?
>>>For the moment we are using Marshal by reference, so all my object derive
>>>from MarshalByRef.
>>
>>Classes must be serializable to be able to transport them by value.
>>
>>Bye
>>Rob
>>

Sam Santiago

8/31/2004 4:09:00 PM

0

Do you implement the ISerializable interface or do you only mark your class
as [Serializable]? You might want to post your class code here.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Henke" <Henke@discussions.microsoft.com> wrote in message
news:B0A69B78-E885-487A-8673-D4B9EE3894BF@microsoft.com...
> Sorry, I don't get any other message. The object I try to marshal only has
a
> private int, a private string member and two public properties.
>
> /Henke
>
> "Robert Jordan" wrote:
>
> > Hi,
> >
> > > I have tried to mark them with:
> > > [Serializable]
> > >
> > > but when I try to connect to the object I get this exception:
> > > An unhandled exception of type
'System.Runtime.Remoting.RemotingException'
> > > occurred in mscorlib.dll
> > > Additional information: Trying to create a proxy to an unbound type.
> >
> > probably because one of the fields of the classes you declared
> > [Serializable] is not serializable (because its type is
> > not declared [Serializable]).
> >
> > try using this settings in your App.config. you'll get
> > the exact exception instead the generic
> > System.Runtime.Remoting.RemotingException:
> >
> > <configuration>
> > <system.runtime.remoting>
> > <customErrors mode="off" />
> > </system.runtime.remoting>
> > </configuration>
> >
> >
> > > If I derive the object from MarshalByRef everything works fine, except
that
> > > I get a reference instead of the object :)
> >
> > Well, it is much easier to get an object marshaled by ref
> > then by value. the reason: marshal by value expects
> > that the whole object graph of a certain object is serializable,
> > because the remoting infrastructure has to transfer a copy
> > of the data over the wire.
> >
> > bye
> > Rob
> >
> >
> > >
> > > "Robert Jordan" wrote:
> > >
> > >
> > >>Henke wrote:
> > >>
> > >>
> > >>>Hi!
> > >>>What actions do I have to do in order to get my objects marshaled by
value?
> > >>>For the moment we are using Marshal by reference, so all my object
derive
> > >>>from MarshalByRef.
> > >>
> > >>Classes must be serializable to be able to transport them by value.
> > >>
> > >>Bye
> > >>Rob
> > >>
> >