[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

passing object ByRef not updating object references

google

10/14/2004 2:16:00 PM

Hi,

I'm fairly new to remoting, and I'm running into problems passing
objects as arguments to a remote method when there are multiple
references to that object on the client.

An example:

On the client side I have two references to a single instance of
MyBusinessObject: x and y. In my remote object, I have a method (sub)
that takes a MyBusinessObject as a parameter ByRef and makes some
change to it (increments a counter, e.g.). If I call this method
passing x as my argument, once control returns to the client, I can
see that x contains the updated data. Y does not. X and Y no longer
refer to the same object (x.Equals(y)=False).

Anyone have any thoughts as to what I'm doing wrong?

I'm running on version 1.1 SP1 of the framework, using remoting
through IIS.

Thanks!
-Melissa Lewis
12 Answers

Sam Santiago

10/14/2004 3:54:00 PM

0

Are you reassigning the variable in your call, i.e. x = myRemoteMethod(x)?
Also, are you marshaling by value or reference - Is MyBusinessObject derived
from MarshalByRefObject or is it simply serializable? It should be derived
from MarshalByRefObject is you want changes made on the server reflected on
the client, unless you do a reassignment like above for a serializable
object.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Melissa Lewis" <google@thisismyproblemhow.com> wrote in message
news:9ec3823f.0410140615.6233c13a@posting.google.com...
> Hi,
>
> I'm fairly new to remoting, and I'm running into problems passing
> objects as arguments to a remote method when there are multiple
> references to that object on the client.
>
> An example:
>
> On the client side I have two references to a single instance of
> MyBusinessObject: x and y. In my remote object, I have a method (sub)
> that takes a MyBusinessObject as a parameter ByRef and makes some
> change to it (increments a counter, e.g.). If I call this method
> passing x as my argument, once control returns to the client, I can
> see that x contains the updated data. Y does not. X and Y no longer
> refer to the same object (x.Equals(y)=False).
>
> Anyone have any thoughts as to what I'm doing wrong?
>
> I'm running on version 1.1 SP1 of the framework, using remoting
> through IIS.
>
> Thanks!
> -Melissa Lewis


Melissa Lewis

10/14/2004 5:48:00 PM

0

<snip>
Are you reassigning the variable in your call, i.e. x =
myRemoteMethod(x)? Also, are you marshaling by value or reference - Is
MyBusinessObject derived from MarshalByRefObject or is it simply
serializable? It should be derived from MarshalByRefObject is you want
changes made on the server reflected on the client, unless you do a
reassignment like above for a serializable object.
</snip>

Hi,

No, I am not reassigning anything--my remote method is a VB subroutine.
MyBusinessObject is serializable, not inherited from MarshalByRefObject.

I guess I'm confused as to why I would have to have it inherit from
MarshalByRefObject. I do get the updates to x using ByRef in the method
signature with a serializable MyBusinessObject; it just seems that I'm
getting a different object returned, unhooked from the other references
("y", in my example).

If I were to change this to a function that returned a MyBusinessObject,
wouldn't I have to find my other references to that instance and point
them all to the new copy? Maybe I'm just being cranky, but that seems
really fragile to me.

Thanks!
-Melissa


*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!

Sam Santiago

10/14/2004 6:55:00 PM

0

When you use a ByRef parameter in remoting, the remoting infrastructure
serializes your object sends it to the server, performs any changes on it,
then serializes back to your client, where it is deserialized and made a new
object. That is why x points to a changed object, but the other references
do not.
If you want to have all references to reflect the change, then you can
derive your object from the MarshalByRefObject. Then in effect your client
becomes a remoting "server" and the server becomes the "client". A proxy is
sent to the server and any access to your client object must cross
process/network boundaries, but a new object is not created upon return like
in your current scenario.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Melissa Lewis" <devdex@thisismyproblemhow.com> wrote in message
news:%23X7V2XhsEHA.2264@TK2MSFTNGP15.phx.gbl...
> <snip>
> Are you reassigning the variable in your call, i.e. x =
> myRemoteMethod(x)? Also, are you marshaling by value or reference - Is
> MyBusinessObject derived from MarshalByRefObject or is it simply
> serializable? It should be derived from MarshalByRefObject is you want
> changes made on the server reflected on the client, unless you do a
> reassignment like above for a serializable object.
> </snip>
>
> Hi,
>
> No, I am not reassigning anything--my remote method is a VB subroutine.
> MyBusinessObject is serializable, not inherited from MarshalByRefObject.
>
> I guess I'm confused as to why I would have to have it inherit from
> MarshalByRefObject. I do get the updates to x using ByRef in the method
> signature with a serializable MyBusinessObject; it just seems that I'm
> getting a different object returned, unhooked from the other references
> ("y", in my example).
>
> If I were to change this to a function that returned a MyBusinessObject,
> wouldn't I have to find my other references to that instance and point
> them all to the new copy? Maybe I'm just being cranky, but that seems
> really fragile to me.
>
> Thanks!
> -Melissa
>
>
> *** Sent via Developersdex http://www.develop... ***
> Don't just participate in USENET...get rewarded for it!


Melissa Lewis

10/14/2004 7:27:00 PM

0

OK, I'll give that a whirl.

Thanks, Sam!
-Melissa



*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!

Nathan

11/5/2004 7:11:00 AM

0

I hope you see this Sam,
I think my issue is similar. Server(marshalbyref)-Interface-Client.

The client calls a Property(writeonly) passing a string which I would like
to change a variable on the server.

The property DOES change the server variable throughout the implements as I
can write to the log the new variable, but later on in the server, let's say
on a timed event, I write to the log the same variable that I "thought" was
changed.
Instead it writes the original value.

It's like the client, when connecting to the server is getting a whole new
instance of the server class and the server is still doing it's own thing.
Can somebody help me understand this?

Thanks,
Nathan

Sam Santiago

11/5/2004 8:16:00 AM

0

Two things come to mind:

1) Are you overriding the InitializeLifetimeService on your object if you
are using SAO Singletons? If you want a true Singleton be sure to override
the InitializeLifetimeService method provided from the MarshalByRefObject to
return null. Some of the behavior you're observing might be due to the fact
that your object's lifetime lease has expired (5 min default from the last
method call) and a new object is created when you invoke your SAO after a
few minutes.

2) Properties (Instance Fields with only a Set accessor in your case) are
not remoteable. You'll have to use a public method to set your server
variable. Check out this link:

Scope of Publication
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconscopeofpubli...

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Nathan" <Nathan@discussions.microsoft.com> wrote in message
news:82337407-D9C3-4BF1-BEC2-420A3558385C@microsoft.com...
> I hope you see this Sam,
> I think my issue is similar. Server(marshalbyref)-Interface-Client.
>
> The client calls a Property(writeonly) passing a string which I would like
> to change a variable on the server.
>
> The property DOES change the server variable throughout the implements as
I
> can write to the log the new variable, but later on in the server, let's
say
> on a timed event, I write to the log the same variable that I "thought"
was
> changed.
> Instead it writes the original value.
>
> It's like the client, when connecting to the server is getting a whole new
> instance of the server class and the server is still doing it's own thing.
> Can somebody help me understand this?
>
> Thanks,
> Nathan


Nathan

11/5/2004 4:03:00 PM

0

Thanks for a quick reply Sam, but I'm afraid nothing has changed as of yet.
I tried to override the ILS but that didn't make a difference.
Just in case the Property was the issue, I also had a sub that changed the
variable that I could access through the interface and the same effect would
happen (makes me wonder about the Property, how it wouldn't err on me and
would perform everything in it, when you say it shouldn't.)
Here is a quick clip of what is going on:
***********************
Server-
Friend Class SharedClass
Inherits MarshalByRefObject
Implements TInterface.Server_Interface
WriteOnly Property CurrentUserProp() As String Implements
TInterface.Server_Interface.CurrentUserProp
Set(ByVal value As String)
Me.CurrentUser = value
If value = Nothing Then
Me.ClientOpen = False
Else
Me.ClientOpen = True
End If
End Set
End Property
Public Sub ClientChanged(ByVal test As String) Implements
TInterface.Server_Interface.ClientChanged
Me.CurrentUser = test
End Sub
Protected Friend Sub RunFirst()
Dim Provider As New
Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
Provider.TypeFilterLevel =
Runtime.Serialization.Formatters.TypeFilterLevel.Full
RServer = New
Runtime.Remoting.Channels.Ipc.IpcServerChannel("TChannel", "TChannel",
Provider)

Runtime.Remoting.Channels.ChannelServices.RegisterChannel(Me.RServer)

Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)
End Sub
***********************
Interface-
Public Interface Server_Interface
WriteOnly Property CurrentUserProp() As String
Sub ClientChanged(ByVal ChangedVal As String)
End Interface
***********************
Client-
Runtime.Remoting.Channels.ChannelServices.RegisterChannel(RClient)
RemoteObject =
Activator.GetObject(GetType(TInterface.Server_Interface),
"ipc://TChannel/SharedClass")
Me.RemoteObject.ClientChanged(My.User.Identity.Name)
***********************
So, from this, the CurrentUser var has already been assigned a val when the
server starts. The client connects and sends a new val (either by using
clientchanged sub or the CurrentUserProp property) and will write to the log
showing the new val.
Now I'll keep the client connected and stop the server and in the process,
have it write to the log the CurrentUser val which ends up being the original
value. This is all in a span of < 1 minute.

Appreciating the help,
Nathan

"Sam Santiago" wrote:

> Two things come to mind:
>
> 1) Are you overriding the InitializeLifetimeService on your object if you
> are using SAO Singletons? If you want a true Singleton be sure to override
> the InitializeLifetimeService method provided from the MarshalByRefObject to
> return null. Some of the behavior you're observing might be due to the fact
> that your object's lifetime lease has expired (5 min default from the last
> method call) and a new object is created when you invoke your SAO after a
> few minutes.
>
> 2) Properties (Instance Fields with only a Set accessor in your case) are
> not remoteable. You'll have to use a public method to set your server
> variable. Check out this link:
>
> Scope of Publication
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconscopeofpubli...
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTe...
> _______________________________
> "Nathan" <Nathan@discussions.microsoft.com> wrote in message
> news:82337407-D9C3-4BF1-BEC2-420A3558385C@microsoft.com...
> > I hope you see this Sam,
> > I think my issue is similar. Server(marshalbyref)-Interface-Client.
> >
> > The client calls a Property(writeonly) passing a string which I would like
> > to change a variable on the server.
> >
> > The property DOES change the server variable throughout the implements as
> I
> > can write to the log the new variable, but later on in the server, let's
> say
> > on a timed event, I write to the log the same variable that I "thought"
> was
> > changed.
> > Instead it writes the original value.
> >
> > It's like the client, when connecting to the server is getting a whole new
> > instance of the server class and the server is still doing it's own thing.
> > Can somebody help me understand this?
> >
> > Thanks,
> > Nathan
>
>
>

Sam Santiago

11/5/2004 4:47:00 PM

0

I guess you are experimenting with the next release of the .NET framework
since you are using IpcServerChannel which doesn't exist currently. I don't
see anything explicitly wrong with your code down below. Have you tried
debugging the server and the client simultaneously within Visual Studio
2003? If you create a solution containing multiple projects you can right
click on the server and select Debug, Start New Instance. You can then
right click on the client project and select Debug, Step into New Instance.
You can set breakpoints in both apps and be able to step through code in
both apps.

Thanks,

Sam

--
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTe...
_______________________________
"Nathan" <Nathan@discussions.microsoft.com> wrote in message
news:182B9897-07F1-4ABC-B6CC-4A6787D31B72@microsoft.com...
> Thanks for a quick reply Sam, but I'm afraid nothing has changed as of
yet.
> I tried to override the ILS but that didn't make a difference.
> Just in case the Property was the issue, I also had a sub that changed the
> variable that I could access through the interface and the same effect
would
> happen (makes me wonder about the Property, how it wouldn't err on me and
> would perform everything in it, when you say it shouldn't.)
> Here is a quick clip of what is going on:
> ***********************
> Server-
> Friend Class SharedClass
> Inherits MarshalByRefObject
> Implements TInterface.Server_Interface
> WriteOnly Property CurrentUserProp() As String Implements
> TInterface.Server_Interface.CurrentUserProp
> Set(ByVal value As String)
> Me.CurrentUser = value
> If value = Nothing Then
> Me.ClientOpen = False
> Else
> Me.ClientOpen = True
> End If
> End Set
> End Property
> Public Sub ClientChanged(ByVal test As String) Implements
> TInterface.Server_Interface.ClientChanged
> Me.CurrentUser = test
> End Sub
> Protected Friend Sub RunFirst()
> Dim Provider As New
> Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
> Provider.TypeFilterLevel =
> Runtime.Serialization.Formatters.TypeFilterLevel.Full
> RServer = New
> Runtime.Remoting.Channels.Ipc.IpcServerChannel("TChannel", "TChannel",
> Provider)
>
> Runtime.Remoting.Channels.ChannelServices.RegisterChannel(Me.RServer)
>
>
Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(
SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)
> End Sub
> ***********************
> Interface-
> Public Interface Server_Interface
> WriteOnly Property CurrentUserProp() As String
> Sub ClientChanged(ByVal ChangedVal As String)
> End Interface
> ***********************
> Client-
>
Runtime.Remoting.Channels.ChannelServices.RegisterChannel(RClient)
> RemoteObject =
> Activator.GetObject(GetType(TInterface.Server_Interface),
> "ipc://TChannel/SharedClass")
> Me.RemoteObject.ClientChanged(My.User.Identity.Name)
> ***********************
> So, from this, the CurrentUser var has already been assigned a val when
the
> server starts. The client connects and sends a new val (either by using
> clientchanged sub or the CurrentUserProp property) and will write to the
log
> showing the new val.
> Now I'll keep the client connected and stop the server and in the process,
> have it write to the log the CurrentUser val which ends up being the
original
> value. This is all in a span of < 1 minute.
>
> Appreciating the help,
> Nathan
>
> "Sam Santiago" wrote:
>
> > Two things come to mind:
> >
> > 1) Are you overriding the InitializeLifetimeService on your object if
you
> > are using SAO Singletons? If you want a true Singleton be sure to
override
> > the InitializeLifetimeService method provided from the
MarshalByRefObject to
> > return null. Some of the behavior you're observing might be due to the
fact
> > that your object's lifetime lease has expired (5 min default from the
last
> > method call) and a new object is created when you invoke your SAO after
a
> > few minutes.
> >
> > 2) Properties (Instance Fields with only a Set accessor in your case)
are
> > not remoteable. You'll have to use a public method to set your server
> > variable. Check out this link:
> >
> > Scope of Publication
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconscopeofpubli...
> >
> > Thanks,
> >
> > Sam
> >
> > --
> > _______________________________
> > Sam Santiago
> > ssantiago@n0spam-SoftiTechture.com
> > http://www.SoftiTe...
> > _______________________________
> > "Nathan" <Nathan@discussions.microsoft.com> wrote in message
> > news:82337407-D9C3-4BF1-BEC2-420A3558385C@microsoft.com...
> > > I hope you see this Sam,
> > > I think my issue is similar. Server(marshalbyref)-Interface-Client.
> > >
> > > The client calls a Property(writeonly) passing a string which I would
like
> > > to change a variable on the server.
> > >
> > > The property DOES change the server variable throughout the implements
as
> > I
> > > can write to the log the new variable, but later on in the server,
let's
> > say
> > > on a timed event, I write to the log the same variable that I
"thought"
> > was
> > > changed.
> > > Instead it writes the original value.
> > >
> > > It's like the client, when connecting to the server is getting a whole
new
> > > instance of the server class and the server is still doing it's own
thing.
> > > Can somebody help me understand this?
> > >
> > > Thanks,
> > > Nathan
> >
> >
> >


Ken Kolda

11/5/2004 4:48:00 PM

0

You said that you "stop the server and in the process, have it write to the
log the CurrentUser val". How do you get a hold of the SharedClass instance
that's being remoted in order to write this value to the log? My guess is
that you're creating an instance of SharedClass in your server code and
expecting that instance to be the one which will be used by remote clients.
The way you have your code currently, that will not be the case. If you want
it to work that way, you need to replace this line of code:

Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(
SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)

with

RemotingServices.Marshal(Me, "SharedClass");

Hope that helps -
Ken


"Nathan" <Nathan@discussions.microsoft.com> wrote in message
news:182B9897-07F1-4ABC-B6CC-4A6787D31B72@microsoft.com...
> Thanks for a quick reply Sam, but I'm afraid nothing has changed as of
yet.
> I tried to override the ILS but that didn't make a difference.
> Just in case the Property was the issue, I also had a sub that changed the
> variable that I could access through the interface and the same effect
would
> happen (makes me wonder about the Property, how it wouldn't err on me and
> would perform everything in it, when you say it shouldn't.)
> Here is a quick clip of what is going on:
> ***********************
> Server-
> Friend Class SharedClass
> Inherits MarshalByRefObject
> Implements TInterface.Server_Interface
> WriteOnly Property CurrentUserProp() As String Implements
> TInterface.Server_Interface.CurrentUserProp
> Set(ByVal value As String)
> Me.CurrentUser = value
> If value = Nothing Then
> Me.ClientOpen = False
> Else
> Me.ClientOpen = True
> End If
> End Set
> End Property
> Public Sub ClientChanged(ByVal test As String) Implements
> TInterface.Server_Interface.ClientChanged
> Me.CurrentUser = test
> End Sub
> Protected Friend Sub RunFirst()
> Dim Provider As New
> Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
> Provider.TypeFilterLevel =
> Runtime.Serialization.Formatters.TypeFilterLevel.Full
> RServer = New
> Runtime.Remoting.Channels.Ipc.IpcServerChannel("TChannel", "TChannel",
> Provider)
>
> Runtime.Remoting.Channels.ChannelServices.RegisterChannel(Me.RServer)
>
>
Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(
SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)
> End Sub
> ***********************
> Interface-
> Public Interface Server_Interface
> WriteOnly Property CurrentUserProp() As String
> Sub ClientChanged(ByVal ChangedVal As String)
> End Interface
> ***********************
> Client-
>
Runtime.Remoting.Channels.ChannelServices.RegisterChannel(RClient)
> RemoteObject =
> Activator.GetObject(GetType(TInterface.Server_Interface),
> "ipc://TChannel/SharedClass")
> Me.RemoteObject.ClientChanged(My.User.Identity.Name)
> ***********************
> So, from this, the CurrentUser var has already been assigned a val when
the
> server starts. The client connects and sends a new val (either by using
> clientchanged sub or the CurrentUserProp property) and will write to the
log
> showing the new val.
> Now I'll keep the client connected and stop the server and in the process,
> have it write to the log the CurrentUser val which ends up being the
original
> value. This is all in a span of < 1 minute.
>
> Appreciating the help,
> Nathan
>
> "Sam Santiago" wrote:
>
> > Two things come to mind:
> >
> > 1) Are you overriding the InitializeLifetimeService on your object if
you
> > are using SAO Singletons? If you want a true Singleton be sure to
override
> > the InitializeLifetimeService method provided from the
MarshalByRefObject to
> > return null. Some of the behavior you're observing might be due to the
fact
> > that your object's lifetime lease has expired (5 min default from the
last
> > method call) and a new object is created when you invoke your SAO after
a
> > few minutes.
> >
> > 2) Properties (Instance Fields with only a Set accessor in your case)
are
> > not remoteable. You'll have to use a public method to set your server
> > variable. Check out this link:
> >
> > Scope of Publication
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconscopeofpubli...
> >
> > Thanks,
> >
> > Sam
> >
> > --
> > _______________________________
> > Sam Santiago
> > ssantiago@n0spam-SoftiTechture.com
> > http://www.SoftiTe...
> > _______________________________
> > "Nathan" <Nathan@discussions.microsoft.com> wrote in message
> > news:82337407-D9C3-4BF1-BEC2-420A3558385C@microsoft.com...
> > > I hope you see this Sam,
> > > I think my issue is similar. Server(marshalbyref)-Interface-Client.
> > >
> > > The client calls a Property(writeonly) passing a string which I would
like
> > > to change a variable on the server.
> > >
> > > The property DOES change the server variable throughout the implements
as
> > I
> > > can write to the log the new variable, but later on in the server,
let's
> > say
> > > on a timed event, I write to the log the same variable that I
"thought"
> > was
> > > changed.
> > > Instead it writes the original value.
> > >
> > > It's like the client, when connecting to the server is getting a whole
new
> > > instance of the server class and the server is still doing it's own
thing.
> > > Can somebody help me understand this?
> > >
> > > Thanks,
> > > Nathan
> >
> >
> >


Nathan

11/5/2004 5:53:00 PM

0

By jove, I think he's got it!
Ahhh, kudos for you and Sam for being so on with remoting, and sharing your
knowledge.
The RemotingServices.Marshal did the trick. I'll have to read about it a
smidge to make sure there aren't any downsides, but that was right on.

A very appreciative,
Nathan

"Ken Kolda" wrote:

> You said that you "stop the server and in the process, have it write to the
> log the CurrentUser val". How do you get a hold of the SharedClass instance
> that's being remoted in order to write this value to the log? My guess is
> that you're creating an instance of SharedClass in your server code and
> expecting that instance to be the one which will be used by remote clients.
> The way you have your code currently, that will not be the case. If you want
> it to work that way, you need to replace this line of code:
>
> Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(
> SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)
>
> with
>
> RemotingServices.Marshal(Me, "SharedClass");
>
> Hope that helps -
> Ken
>
>
> "Nathan" <Nathan@discussions.microsoft.com> wrote in message
> news:182B9897-07F1-4ABC-B6CC-4A6787D31B72@microsoft.com...
> > Thanks for a quick reply Sam, but I'm afraid nothing has changed as of
> yet.
> > I tried to override the ILS but that didn't make a difference.
> > Just in case the Property was the issue, I also had a sub that changed the
> > variable that I could access through the interface and the same effect
> would
> > happen (makes me wonder about the Property, how it wouldn't err on me and
> > would perform everything in it, when you say it shouldn't.)
> > Here is a quick clip of what is going on:
> > ***********************
> > Server-
> > Friend Class SharedClass
> > Inherits MarshalByRefObject
> > Implements TInterface.Server_Interface
> > WriteOnly Property CurrentUserProp() As String Implements
> > TInterface.Server_Interface.CurrentUserProp
> > Set(ByVal value As String)
> > Me.CurrentUser = value
> > If value = Nothing Then
> > Me.ClientOpen = False
> > Else
> > Me.ClientOpen = True
> > End If
> > End Set
> > End Property
> > Public Sub ClientChanged(ByVal test As String) Implements
> > TInterface.Server_Interface.ClientChanged
> > Me.CurrentUser = test
> > End Sub
> > Protected Friend Sub RunFirst()
> > Dim Provider As New
> > Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider
> > Provider.TypeFilterLevel =
> > Runtime.Serialization.Formatters.TypeFilterLevel.Full
> > RServer = New
> > Runtime.Remoting.Channels.Ipc.IpcServerChannel("TChannel", "TChannel",
> > Provider)
> >
> > Runtime.Remoting.Channels.ChannelServices.RegisterChannel(Me.RServer)
> >
> >
> Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType(GetType(
> SharedClass), "SharedClass", Runtime.Remoting.WellKnownObjectMode.Singleton)
> > End Sub
> > ***********************
> > Interface-
> > Public Interface Server_Interface
> > WriteOnly Property CurrentUserProp() As String
> > Sub ClientChanged(ByVal ChangedVal As String)
> > End Interface
> > ***********************
> > Client-
> >
> Runtime.Remoting.Channels.ChannelServices.RegisterChannel(RClient)
> > RemoteObject =
> > Activator.GetObject(GetType(TInterface.Server_Interface),
> > "ipc://TChannel/SharedClass")
> > Me.RemoteObject.ClientChanged(My.User.Identity.Name)
> > ***********************
> > So, from this, the CurrentUser var has already been assigned a val when
> the
> > server starts. The client connects and sends a new val (either by using
> > clientchanged sub or the CurrentUserProp property) and will write to the
> log
> > showing the new val.
> > Now I'll keep the client connected and stop the server and in the process,
> > have it write to the log the CurrentUser val which ends up being the
> original
> > value. This is all in a span of < 1 minute.
> >
> > Appreciating the help,
> > Nathan
> >
> > "Sam Santiago" wrote:
> >
> > > Two things come to mind:
> > >
> > > 1) Are you overriding the InitializeLifetimeService on your object if
> you
> > > are using SAO Singletons? If you want a true Singleton be sure to
> override
> > > the InitializeLifetimeService method provided from the
> MarshalByRefObject to
> > > return null. Some of the behavior you're observing might be due to the
> fact
> > > that your object's lifetime lease has expired (5 min default from the
> last
> > > method call) and a new object is created when you invoke your SAO after
> a
> > > few minutes.
> > >
> > > 2) Properties (Instance Fields with only a Set accessor in your case)
> are
> > > not remoteable. You'll have to use a public method to set your server
> > > variable. Check out this link:
> > >
> > > Scope of Publication
> > >
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconscopeofpubli...
> > >
> > > Thanks,
> > >
> > > Sam
> > >
> > > --
> > > _______________________________
> > > Sam Santiago
> > > ssantiago@n0spam-SoftiTechture.com
> > > http://www.SoftiTe...
> > > _______________________________
> > > "Nathan" <Nathan@discussions.microsoft.com> wrote in message
> > > news:82337407-D9C3-4BF1-BEC2-420A3558385C@microsoft.com...
> > > > I hope you see this Sam,
> > > > I think my issue is similar. Server(marshalbyref)-Interface-Client.
> > > >
> > > > The client calls a Property(writeonly) passing a string which I would
> like
> > > > to change a variable on the server.
> > > >
> > > > The property DOES change the server variable throughout the implements
> as
> > > I
> > > > can write to the log the new variable, but later on in the server,
> let's
> > > say
> > > > on a timed event, I write to the log the same variable that I
> "thought"
> > > was
> > > > changed.
> > > > Instead it writes the original value.
> > > >
> > > > It's like the client, when connecting to the server is getting a whole
> new
> > > > instance of the server class and the server is still doing it's own
> thing.
> > > > Can somebody help me understand this?
> > > >
> > > > Thanks,
> > > > Nathan
> > >
> > >
> > >
>
>
>