473,511 Members | 17,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4406
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7971
by: Pete Loveall | last post by:
I have a server application that monitors a private local queue for messages. The message sent to it has a label and a response queue defined. It works correctly when the queue is accessed via...
0
4035
by: Kimmo Laine | last post by:
Hi, how can i be sure that the MSMQ Message.Body property contains something valid? If i send the message like this: public void SendMyMessage( int msgCode, object msgData ) { Message msg =...
3
4349
by: Stephan Schlicker | last post by:
Hi everyone I have a serious problem with the serilization of an user-defined object in C#. I would like to serialize an object of class D which inherits from class C. Class C as well as class D...
1
2660
by: Jim S | last post by:
I have an application where I have to make a tree of objects. To do this, I have my own node class. At certain points in the application, I need to save data. I am having a problem with the...
2
2416
by: alexandre martins | last post by:
Every time i try to make Deserialize the computer gives me the folowing error: "End of Stream encountered before parsing was complete" the code that i'm running is simple and is based on an...
1
310
by: CLEAR-RCIC | last post by:
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."...
1
1351
by: parez | last post by:
I am trying to use msmq to send messages(serialised object) from a .net 1.1 webapp to .net 2.0 windows service. Is it possible? If yes then will the binary formatter work ?
4
6259
by: IdleBrain | last post by:
I wrote an application that puts in a message into MSMQ using C++ and MFC. If I try to put a message called 'sample' I see that the body of the message in MSMQ would be set to: 's.a.m.p.l.e'. ...
2
12115
by: Chizl | last post by:
On the MQReceiveCompleted method below, I get an error "Name cannot begin with the '.' character, hexadecimal value 0x00. Line 1, position 40.".. This data is XML that I'm putting into this queue....
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.