HighTechTalks DotNet Forums  

Remoted object passes blank properties to client

Dotnet Framework (Remoting) microsoft.public.dotnet.framework.remoting


Discuss Remoted object passes blank properties to client in the Dotnet Framework (Remoting) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
miles3719@msn.com
 
Posts: n/a

Default Remoted object passes blank properties to client - 10-02-2007 , 11:46 AM






Hello there,

I've scoured the web for a couple of hours now trying to find a
solution to my problem so I am going to resort to asking the wider
world for assistance. I'm sure it's going to be a simple thing but I
just cant make it work.

Consider the following server activation code


Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.http
Imports CommonCode
Public Module rPhoneServer
Dim strSite As String = String.Empty
Sub Main()
If GetParamValue("Site", strSite) = 1 Then
RemotingConfiguration.Configure("rPhoneServer.exe. config",
False)
Dim MyServerObj As New CommonCode.rPhone
MyServerObj.Startup(strSite)
MyServerObj.Site = strSite
Console.WriteLine("Starting Server. HashCode = " &
MyServerObj.GetHash)
Console.WriteLine()
Console.WriteLine("Press any key to exit...")
MyServerObj.StartProcessing()
Else
Console.WriteLine("Main:: No site specified on command
line (/site, Exiting")
End If
End Sub
End Module


The remote object looks like this

Public Class rPhone
Inherits MarshalByRefObject

Public Declare Function Sleep Lib "Kernel32" (ByVal Milliseconds
As Integer) As Integer

Shared strSite As String
......
etc
.....


Now on the client with code
Public Function Startup() As Integer
RemotingConfiguration.Configure("rPhoneClient.exe. config",
False)
CommoncodeRPhone = New CommonCode.rPhone
....
etc
....
When I run

MsgBox(CommoncodeRPhone.Site)

I get a blank string "" rather than "TDOC" which is set back in

MyServerObj.Startup(strSite)
MyServerObj.Site = strSite

i know that strsite is holding the value "TDOC" because I debug
through it and I can see it setting it, just as I can have a function
running in the server console app that just prints the value of Site
and it prints "TDOC" every time, but on the client it prints nothing.

Just to make sure I was referring to the same object I created

Public Function GetHash() As String
Return Me.GetType.GetHashCode.ToString
End Function

In the remotable class and sure enough it returns the same value on
the server and on the client.

I can post more files should you require more information (or the
entire solution if need be)

Can someone please tell me what I am doing wrong, as If I set Site on
the server.... when I query the site property on the clients I want it
to reflect the same value, which I thought was the whole idea of a
singleton implementation?

Cheers,
Aaron


Reply With Quote
  #2  
Old   
Azza
 
Posts: n/a

Default Re: Remoted object passes blank properties to client - 10-02-2007 , 12:28 PM






Well I seem to have have made it work. I changed two things

Firstly in the server module it now looks like

Sub Main()
If GetParamValue("Site", strSite) = 1 Then
RemotingConfiguration.Configure("rPhoneServer.exe. config",
False)
Dim MyServerObj As New CommonCode.rPhone
Dim refMessenger As ObjRef
'Dynamically publish the object - all clients will get ref
to this same instance
refMessenger = RemotingServices.Marshal(MyServerObj,
"Messenger.soap")
MyServerObj.Startup(strSite)
Console.WriteLine("Starting Server. HashCode = " &
MyServerObj.GetHash)
Console.WriteLine(MyServerObj.whatever)
Console.WriteLine()
Console.WriteLine("Press any key to exit...")
MyServerObj.StartProcessing()
Else
Console.WriteLine("Main:: No site specified on command line
(/site, Exiting")
End If
End Sub
End Module


having added

Dim refMessenger As ObjRef
refMessenger = RemotingServices.Marshal(MyServerObj, "Messenger.soap")

To be honest Im not sure what it's actually doing since I am not
actually referring to the refMessenger variable anywhere.....

that... and I changed the remotable classes variables to 'Shared' (they
were 'Private')

Seems to be working at the moment, but no doubt something else will
break in the near future

Cheers,
Aaron



miles3719 (AT) msn (DOT) com wrote:
Quote:
Hello there,

I've scoured the web for a couple of hours now trying to find a
solution to my problem so I am going to resort to asking the wider
world for assistance. I'm sure it's going to be a simple thing but I
just cant make it work.

Consider the following server activation code


Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.http
Imports CommonCode
Public Module rPhoneServer
Dim strSite As String = String.Empty
Sub Main()
If GetParamValue("Site", strSite) = 1 Then
RemotingConfiguration.Configure("rPhoneServer.exe. config",
False)
Dim MyServerObj As New CommonCode.rPhone
MyServerObj.Startup(strSite)
MyServerObj.Site = strSite
Console.WriteLine("Starting Server. HashCode = " &
MyServerObj.GetHash)
Console.WriteLine()
Console.WriteLine("Press any key to exit...")
MyServerObj.StartProcessing()
Else
Console.WriteLine("Main:: No site specified on command
line (/site, Exiting")
End If
End Sub
End Module


The remote object looks like this

Public Class rPhone
Inherits MarshalByRefObject

Public Declare Function Sleep Lib "Kernel32" (ByVal Milliseconds
As Integer) As Integer

Shared strSite As String
.....
etc
....


Now on the client with code
Public Function Startup() As Integer
RemotingConfiguration.Configure("rPhoneClient.exe. config",
False)
CommoncodeRPhone = New CommonCode.rPhone
...
etc
...
When I run

MsgBox(CommoncodeRPhone.Site)

I get a blank string "" rather than "TDOC" which is set back in

MyServerObj.Startup(strSite)
MyServerObj.Site = strSite

i know that strsite is holding the value "TDOC" because I debug
through it and I can see it setting it, just as I can have a function
running in the server console app that just prints the value of Site
and it prints "TDOC" every time, but on the client it prints nothing.

Just to make sure I was referring to the same object I created

Public Function GetHash() As String
Return Me.GetType.GetHashCode.ToString
End Function

In the remotable class and sure enough it returns the same value on
the server and on the client.

I can post more files should you require more information (or the
entire solution if need be)

Can someone please tell me what I am doing wrong, as If I set Site on
the server.... when I query the site property on the clients I want it
to reflect the same value, which I thought was the whole idea of a
singleton implementation?

Cheers,
Aaron


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.