I'm pretty stuck on this one so I'm hoping someone out there can help me out.
I'm building a client and server to run on 2 different machines over a network using .NET Remoting. I'm finding that the applications run fine when they are executed on the same machine but that the server is unable to unmarshal the eventsink (MsgEventRepeater) when I run the client on a different machine. The output from tracking services shows the client successfully unmarshaling the remote (server) object and then marshaling the eventsink. Directly after this the following exception is thrown: "No connection could be made because the target machine actively refused it". Similarly on the server, tracking services shows the server successfully marshaling the remote object but it never gets to unmarshaling the eventsink. The only significant difference between my code and the sample code I'm following is that the server object connects to a COM interface on the server but I don't think this is related to the error I'm receiving. I've included the relevant code below, if you've run into this problem as well or have any suggestions then It would be great to hear them. ------------- Client Application: Creating remote object and subscribing to events: RemotingConfiguration.Configure(@"..\..\IRDAClient.exe.config"); obj = new ServerObject(); m_MsgEventRepeater = new MsgEventRepeater(); m_MsgEventRepeater.MsgEvent += new MsgEventHandler(this.MyMsgEventHandler); obj.MsgEvent += new MsgEventHandler(m_MsgEventRepeater.Handler); ------------ Event Sink found in the stand-in class and actual implementation class of the assembly on the client and server respectively. public class MsgEventRepeater : MarshalByRefObject { // // event to which clients subscribe public event MsgEventHandler MsgEvent; // // handler method for the IJobServer.JobEvent public void Handler(MsgEventArgs args) { if (MsgEvent != null) { MsgEvent(args); } } // // prevent lifetime services from destroying our instance... public override object InitializeLifetimeService() { return null; } } ------------------- ServerObject imlementation found on the server using System; using WBC_KrcLib; namespace IRDALib { [Serializable] public struct MsgContents { public MsgContents(int nServerID, int nErrorCode, int nMsgHandle) { m_nServerID = nServerID; m_nErrorCode = nErrorCode; m_nMsgHandle = nMsgHandle; } public int m_nServerID; public int m_nErrorCode; public int m_nMsgHandle; } [Serializable] public class MsgEventArgs : System.EventArgs { public enum msgType {ADD,SUB}; private msgType m_Type; private MsgContents m_Contents; public MsgEventArgs(MsgContents NewMsg, msgType Type) { m_Contents = NewMsg; m_Type = Type; } public MsgContents Contents { get { return m_Contents; } set { m_Contents = value;} } public msgType Type { get { return m_Type; } } } public delegate void MsgEventHandler(MsgEventArgs e); public class ServerObject : System.MarshalByRefObject { public ServerObject() { Console.WriteLine(); Console.WriteLine("Remote Object Created."); } public override object InitializeLifetimeService() { return null; } public event MsgEventHandler MsgEvent; public void EventTrigger(MsgEventArgs e) { if (MsgEvent != null) { MsgEvent(e); } } public void SetServerID(int ServerID) { Console.WriteLine("Client allocated ServerID: {0}, to this server",ServerID); #region Cross3Krc Connection Code /// Create a connection to the Cross3Krc Interface string strClientId = "TestAdviseMessage"; ICKAdviseMessage itfAdviseMessage = null; KrcServiceFactoryClass itfKrcServiceFactory = new KrcServiceFactoryClass(); itfAdviseMessage = itfKrcServiceFactory.GetService ("WBC_KrcLib.AdviseMessage", strClientId) as ICKAdviseMessage; clsConsumeMessage itfConsumeMessage = new clsConsumeMessage(this,ServerID); itfAdviseMessage.Advise(itfConsumeMessage,(int) (EKMessageType.eMessageTypeEvent|EKMessageType.eMessageTypeState|EKMessageTy pe.eMessageTypeQuitt)); Console.WriteLine("Connection to Cross3Krc Interface created"); #endregion } } }