.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > Why can't I access my remote object's properties?
 

Why can't I access my remote object's properties?

Ok,

This is my first shot at remoting so please excuse my ignorance

I created a class library called RemotingLib.DLL. I have one class in this library

Public Class HelloWorld
Inherits MarshalByRefObject
'--------------------------------------------------------------------
' Testing .NET remoting
'--------------------------------------------------------------------

private m_Text as String = "Hello World!"

public property HelloString as String
Get
return m_Text
End Get
Set(ByVal value As String)
m_Text = value
End Set
End Property
End Class


I've compiled the dll, created a virtual directory on another machine and added a bin directory. I placed the assembly in the bin directory.
Also, in the IIS virtual directory I added a web.config file that looks like this.

<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" type="RemotingLib.HelloWorld, RemotingLib"
objectUri="HelloWorld.soap" />
</service>
</application>
</system.runtime.remoting>
</configuration>


Now, on my development machine, I created a client app. I added a reference to my RemotingLib.dll.

I created a client.config file that looks like this

<configuration>
<system.runtime.remoting>
<application name="Client">
<client url="http://myserver/RemoteTest">
<wellknown type="RemotingLib.HelloWorld, RemotingLib"
url="http://myserver/RemoteTest/HelloWorld.soap"/>
</client>
<channels>
<channel ref="http" />
</channels>
</application>
</system.runtime.remoting>
</configuration>

Here's the code in my client app

Try
system.Runtime.Remoting.RemotingConfiguration.Configure("client.config", False)

dim MyTestObject as New RemotingLib.HelloWorld

dim MyString as String

MyString = MyTestObject.HelloString()

'This displays the initalz property setting
msgbox("Text = " & MyString)

MyTestObject.HelloString = "BLAH"

'This also displays the initial setting
MyString = MyTestObject.HelloString()

msgbox ("Text = " & MyString)

Catch ex As Exception
msgbox ("Ex " & ex.ToString)
End Try


I've used System.Environment.MachineName in my remote object so I know that it's loading from the host, however, I can't manipulate the property of the class. It seems to have no effect on the value. No matter what I try to set it to it returns "Hello World!" Does anyone have an idea as to what I may be doing wrong?

Thanks in advance to all replies.

budbjames
You have a single call object, so for each call from the client, a new object will be constructed. Holding state ininstance membersdoesn't make sense for single calls. You can do it with client activated objects, if scalability is not a concern.
Lucian Bargaoanu
You have a single call object, so for each call from the client, a new object will be constructed. Holding state ininstance membersdoesn't make sense for single calls. You can do it with client activated objects, if scalability is not a concern.
Lucian Bargaoanu

You can use google to search for other answers

Custom Search

More Threads

• How to suppress base64 encoding of Byte[] streams?
• Server activated objects
• suggestion for a remoteable default membership provider
• Channel already registered
• Problem with IPCClient sample code
• Null Refrence Exception was unhandled{"Object reference not set to an instance of an object."}.
• Trouble with SoapExtension not firing.
• Specific SOAP Object Serialisation
• Problem serialising interface arrays with BinaryFormatter.
• Temporary COM object makes asynchronous calls to persistent .NET 2.0 class library