Hi.
I'm writing a logging service that uses .NET remoting. The idea is that the service publishes an EventProcessor object that clients can access via .NET Remoting, passing it DiagnosticEvent objects for processing.
I've altered the main program for the service slightly so that I can run it more easily as a "regular" application during debugging. I have an assembly that contains the "diagnostics" classes that do the work, the service app itself, and a test client app that lets you create a DiagnosticEvent and "dispatch" it.
That is, I'm trying to pass an argument to a member function of a remotable object. As I understand it, that means I have to mark it as serializable, which I have.
The problem is that I'm getting errors telling me that the DiagnosticEvent object which I'm passing to the remote object is "not marked for serialization" -- even though it is. When I try adding a function that takes a TestObject, expecting the same error, I then get an exception about "unable to load" due to a problem with deserialization.
I'm clearly missing something basic. I'm new to .NET, BTW.
(ASIDE: One more little hitch is that I've been wrestling with static initialization of the remote object. It's a singleton class, and it seems that I get messed up if the server application instantiates the class before remote applications get a chance to. But perhaps that's for another post.)
Can someone help me clear up my serialization issues? Here's some of the code:
The object I'm passing to the remote object is declared as:
Expand|Select|Wrap|Line Numbers
- [Serializable]
- public class DiagnosticEvent : ISimObject
- { . . . }
Expand|Select|Wrap|Line Numbers
- [Serializable]
- public class TestObject
- {
- public int m_Int;
- public string m_String;
- }
Expand|Select|Wrap|Line Numbers
- private static TcpChannel Publish()
- {
- TcpChannel channel = null;
- if (channel == null)
- {
- // Create an instance of a channel
- channel = new TcpChannel(8080);
- ChannelServices.RegisterChannel(channel, false);
- }
- // Register as an available service with the name GEDiag
- RemotingConfiguration.RegisterWellKnownServiceType(
- typeof(GESim.Diagnostics.EventProcessor),
- "GEDiag",
- WellKnownObjectMode.Singleton);
- return channel;
- }
Expand|Select|Wrap|Line Numbers
- private void ConnectToEventProcessor()
- {
- // Create a channel for communicating w/ a remote object
- // Notice no port is specified -- because we're the client.
- if (null == s_Channel)
- {
- s_Channel = new TcpChannel();
- ChannelServices.RegisterChannel(s_Channel, false);
- }
- if (null == m_RemoteEventProcessor)
- {
- // Create an instance of the remote object
- m_RemoteEventProcessor =
- (EventProcessor)Activator.GetObject(
- typeof(EventProcessor),
- "tcp://T00472343:8080/GEDiag");
- }
- }
Expand|Select|Wrap|Line Numbers
- TestObject testObject = new TestObject();
- testObject.m_Int = 45;
- testObject.m_String = "Testing 123...";
- int i = m_RemoteEventProcessor.Test(testObject);
- m_RemoteEventProcessor.EnqueueEvent(theEvent);
Thanks, in advance.