InvalidOperationException

C

Curious

Hi,

I am trying to use the following code to send data over a Message
Queue. The following error is being given:
"An unhandled exception of type 'System.InvalidOperationException'
occurred in system.xml.dll

Additional information: There was an error generating the XML
document."

Can someone help me solve the problem out.
Thanks in Advance

** Code **
MessageQueueCommunication m = new MessageQueueCommunication("myPath");
CommunicationUnit cu = new CommunicationUnit(m, "Test");
MessageQueue mq = new MessageQueue(myPath);
mq.Send(cu);


public abstract class ICommunicationTuple
{
public ICommunicationTuple(){}
}

public class MessageQueueCommunication : ICommunicationTuple
{
private string msgQueuePath;
public MessageQueueCommunication(){}

public MessageQueueCommunication(string messageQueuePath)
{
MessageQueuePath = messageQueuePath;
}

public string MessageQueuePath
{
set { msgQueuePath = value;}
get { return msgQueuePath; }
}
}

public class CommunicationUnit
{
private ICommunicationTuple communicationTuple;
private string communicationType;

public CommunicationUnit(){}
public CommunicationUnit(ICommunicationTuple commTuple, string
commType)
{
CommunicationTuple = commTuple;
CommunicationType = commType;
}

public ICommunicationTuple CommunicationTuple
{
get { return communicationTuple; }
set { communicationTuple = value; }
}

public string CommunicationType
{
set { communicationType = value; }
get { return communicationType; }
}
 
N

Nicholas Paldino [.NET/C# MVP]

Curious,

By default, the message queue classes use an XmlMessageFormatter to
serialize information into the queue (God knows why).

If you have a .NET application listening on the other end, then I would
recommend setting the Formatter property to the BinaryMessageFormatter
class. This will mean that your classes have to be marked as serializable,
but I think you will get better performance as well.

Also, your abstract class should not be named ICommunicationTuple, but
rather, CommunicationTuple, since it is an abstract class, not an interface.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top