I'm having a problem with remoting. It works great for accessing methods
on the proxy of a remote object, but not on data members. When I access a
data member I get:
Unhandled Exception: System.NullReferenceException: A null value was found
where an object instance was required
in <0x00126> 00 TestCode.Remoting.SampleClient:Main (string[])
I'm Attaching the source code for my SampleObject, SampleServer, and
SampleClient.
--
name: Jamin Philip Gray
email: [EMAIL PROTECTED]
icq: 1361499
aim: jamingray47
yahoo: jamin47
web: http://pubcrawler.org
Got Linux?
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace TestCode.Remoting
{
public class SampleObject : MarshalByRefObject
{
public int counter;
public SampleObject()
{
counter = 0;
}
public int GetCount()
{
counter++;
return counter;
}
// Make object live forever
public override Object InitializeLifetimeService()
{
return null;
}
}
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace TestCode.Remoting
{
public class SampleServer
{
public static void Main(string [] args)
{
// Create an instance of a channel
TcpChannel channel = new TcpChannel(8080);
ChannelServices.RegisterChannel(channel);
// Create an instance of our object
SampleObject obj = new SampleObject();
// Publish our object
RemotingServices.Marshal(obj, "SampleObject");
System.Console.WriteLine("Press the enter key to exit...");
System.Console.ReadLine();
}
}
}
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
namespace TestCode.Remoting
{
public class SampleClient
{
public static void Main(string [] args)
{
ChannelServices.RegisterChannel(new TcpChannel());
RemotingConfiguration.RegisterWellKnownClientType(
typeof(SampleObject),
"tcp://localhost:8080/SampleObject");
SampleObject obj = new SampleObject();
// Use the object
if( obj.Equals(null) )
{
System.Console.WriteLine("Error: unable to locate server");
}
else
{
Console.WriteLine("obj.counter: {0}", obj.counter);
while (true)
{
Console.WriteLine("counter: {0}", obj.GetCount());
System.Console.ReadLine();
}
}
}
}
}