orion
New Member
Posts: 2
|
Post by orion on May 18, 2004 3:57:51 GMT -5
I have 2 programs. 1 for sending message to queue. The other for receiving message from queue.
The code fragment for sending message is as follows: Customer c = new Customer(); c.Last = "Doe"; c.First = "John"; Message m = new Message(); m.Body = c; queue.Send(m);
The code fragment for receiving message is as follows: queue.Formatter = new XmlMessageFormatter(new string[] {"Customer", "customer"}); Message m = queue.Receive(); Console.WriteLine("Message got!"); Customer c = (Customer)m.Body;
where "Customer" is the data struct type and "customer" is the assembly containing this data struct.
It sends the msg to the queue successfully. The other program can receive the msg from the queue. But when m.Body is typecasted to Customer. The following error occurs at System.Type.GetType(String typeName, Boolean throwOnError) at System.Messaging.XmlMessageFormatter.CreateTargetSerializerTable() at System.Messaging.XmlMessageFormatter.Read(Message message) at System.Messaging.Message.get_Body()
But when I change the message's body to be string instead of Customer, there will be no problem.
Does anyone have any idea? Many thanks.
|
|
orion
New Member
Posts: 2
|
Post by orion on May 18, 2004 5:37:02 GMT -5
The problem is fixed. I made a laughable mistake. The XmlMessageFormatter's TargetTypeNames should be new String[] {"Customer , customer"}.
|
|