Hello,
I am building a system in C# 2.0 using the master - worker design
pattern
The system is supposed to work as follows:
1. The Master sends Command objects to several workers
2. All Commands are derived from AbstractCommand class (but are
significantly different from each other)
Since the system is distributed and should be presistant, I want to use
MSMQ to pass the Command object to the Workers
The object which I send to the MSMQ is a message containing an object
of type Abstract Command.
The problem is that MSMQ needs the objects passed into the queue to be
serializable.
In order to maintain abstraction and reusability, I want to send the
AbsCommand in the message rather then a specific type of command. when
I try to do this, the MSMQ throws exceptions because of the
serialization of the abstract command contained in the message.
Is there anyway to get around this and to send an object to the msmq
which contains an interface or an abstract object?
Thanks,
Yoni Rabin
//In this illustration, I need to send the message object to the MSMQ
and later read it
// on the other side
[Serializable]
public class message
{
public abstract AbstractCommand;
}
[Serializable]
public abstract class AbstractCommand
{
}
[Serializable]
public class MyCommand:AbstractCommand
{
public string property;