469,609 Members | 1,681 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

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

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$\InputQu eue");
((XmlMessageFormatter)myInputQueue.Formatter).Targ etTypes = 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?
Sep 12 '05 #1
1 4267
Nevermind...I got it working.

"CLEAR-RCIC" wrote:
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$\InputQu eue");
((XmlMessageFormatter)myInputQueue.Formatter).Targ etTypes = 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?

Sep 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Pete Loveall | last post: by
reply views Thread by Kimmo Laine | last post: by
3 posts views Thread by Stephan Schlicker | last post: by
2 posts views Thread by alexandre martins | last post: by
1 post views Thread by parez | last post: by
4 posts views Thread by IdleBrain | last post: by
2 posts views Thread by Chizl | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.