G
Guest
I have a piece of code that works in C# but when I convert it to VB.Net I get
the following error: "Cannot deserialize the message passed as an argument.
Cannot recognize the serialization format."
C# Code
-----------
System.Messaging.MessageQueue myInputQueue = new
System.Messaging.MessageQueue(@".\Private$\InputQueue");
((XmlMessageFormatter)myInputQueue.Formatter).TargetTypes = new
Type[]{typeof(Order)};
Order test1 = new Order();
test1.intID = "123";
System.Messaging.Message m1 = new System.Messaging.Message(test1);
myInputQueue.Send(m1);
System.Messaging.Message m2 = myInputQueue.Receive();
Order test2 = (Order)m2.Body;
MessageBox.Show(test2.SSN);
VB.Net Code
--------------
Dim myMessageQueue As MessageQueue = New MessageQueue(g_strInputQueue)
CType(myMessageQueue.Formatter, XmlMessageFormatter).TargetTypes = (New
Type() {GetType(Order())})
Dim myOrder As Order = New Order
myOrder.intID = "123"
Dim myMessage As Message = New Message(myOrder)
myMessageQueue.Send(myMessage)
Dim myNewMessage As Message = myMessageQueue.Receive
Dim myNewOrder As Order = CType(myNewMessage.Body, Order)
Does anyone have any ideas?
the following error: "Cannot deserialize the message passed as an argument.
Cannot recognize the serialization format."
C# Code
-----------
System.Messaging.MessageQueue myInputQueue = new
System.Messaging.MessageQueue(@".\Private$\InputQueue");
((XmlMessageFormatter)myInputQueue.Formatter).TargetTypes = new
Type[]{typeof(Order)};
Order test1 = new Order();
test1.intID = "123";
System.Messaging.Message m1 = new System.Messaging.Message(test1);
myInputQueue.Send(m1);
System.Messaging.Message m2 = myInputQueue.Receive();
Order test2 = (Order)m2.Body;
MessageBox.Show(test2.SSN);
VB.Net Code
--------------
Dim myMessageQueue As MessageQueue = New MessageQueue(g_strInputQueue)
CType(myMessageQueue.Formatter, XmlMessageFormatter).TargetTypes = (New
Type() {GetType(Order())})
Dim myOrder As Order = New Order
myOrder.intID = "123"
Dim myMessage As Message = New Message(myOrder)
myMessageQueue.Send(myMessage)
Dim myNewMessage As Message = myMessageQueue.Receive
Dim myNewOrder As Order = CType(myNewMessage.Body, Order)
Does anyone have any ideas?