Re: passing object ByRef not updating object references
From: Nathan (Nathan_at_discussions.microsoft.com)
Date: 11/05/04
- Next message: Arne Bernhardt: "IIS 6 probelm??"
- Previous message: Sam Santiago: "Re: web apps + remoting sometimes request queue force to iisreset"
- In reply to: Sam Santiago: "Re: passing object ByRef not updating object references"
- Next in thread: Sam Santiago: "Re: passing object ByRef not updating object references"
- Reply: Sam Santiago: "Re: passing object ByRef not updating object references"
- Reply: Ken Kolda: "Re: passing object ByRef not updating object references"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 5 Nov 2004 08:03:01 -0800
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/cpconscopeofpublication.asp
>
> Thanks,
>
> Sam
>
> --
> _______________________________
> Sam Santiago
> ssantiago@n0spam-SoftiTechture.com
> http://www.SoftiTechture.com
> _______________________________
> "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
>
>
>
- Next message: Arne Bernhardt: "IIS 6 probelm??"
- Previous message: Sam Santiago: "Re: web apps + remoting sometimes request queue force to iisreset"
- In reply to: Sam Santiago: "Re: passing object ByRef not updating object references"
- Next in thread: Sam Santiago: "Re: passing object ByRef not updating object references"
- Reply: Sam Santiago: "Re: passing object ByRef not updating object references"
- Reply: Ken Kolda: "Re: passing object ByRef not updating object references"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|