473,493 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
Create 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 4404
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
7970
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
4034
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
4346
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
2654
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
2412
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
6257
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
12114
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
7119
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
7157
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
6873
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
5453
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,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
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...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
285
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.