I have a Windows Forms application on a server. It has a PeizoGreeter object, which is meant to be a remote object which waits for a store to pass it's store number to it (via AnnounceStoreName).
class PeizoGreeter : MarshalByRefObject
// the GUI listens for remote calls with these
public delegate void PeizoPullEventHandler(object sender, PeizoPullEventArgs e);
public event PeizoPullEventHandler PeizoPullEvent;
// dont need anything here for now...
// allows object to live forever
public override object InitializeLifetimeService()
public void AnnounceStoreName(int storeNumber)
// inform the GUI that this was called
if (PeizoPullEvent != null)
PeizoPullEvent(this, new PeizoPullEventArgs(storeNumber));
I also have a Windows Service. This service waits for a condition to occur, then creates a connection to the remote object and calls AnnounceStoreName, as follows:
ChannelServices.RegisterChannel(new TcpChannel(), true);
PeizoGreeter rmGreeter = new PeizoGreeter();
rmGreeter = (PeizoGreeter)Activator.GetObject(typeof(PeizoGreeter), "tcp://myipaddress:myport/PeizoGreeter");
However, when I attempt to do this, the code fails on the line rmGreeter.AnnounceStoreName, and I get the following Exception and InnerException messages:
Value cannot be null.
Error: Object reference not set to an instance of an object.
I don't understand why this is happening. I took the EXACT same code and plopped it into a console application, and it made the remote function call fine! Why would my windows service (installed with administrator rights) not be able to make this remote call? Clearly, the object is not getting the reference to the remote object.
Any help would be greatly appreciated!!!! After hours of trial and error I am completely stumped.