problems converting C# code to VB.net (MSMQ formatter problem)

problems converting C# code to VB.net (MSMQ formatter problem)

Post by Q0xFQVItUk » Wed, 14 Sep 2005 00:11:04


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?
 
 
 

problems converting C# code to VB.net (MSMQ formatter problem)

Post by Q0xFQVItUk » Wed, 14 Sep 2005 03:12:04

Nevermind...I got it working.