473,790 Members | 2,617 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.Messagin g.MessageQueue myInputQueue = new
System.Messagin g.MessageQueue( @".\Private$\In putQueue");
((XmlMessageFor matter)myInputQ ueue.Formatter) .TargetTypes = new
Type[]{typeof(Order)} ;

Order test1 = new Order();
test1.intID = "123";
System.Messagin g.Message m1 = new System.Messagin g.Message(test1 );
myInputQueue.Se nd(m1);

System.Messagin g.Message m2 = myInputQueue.Re ceive();
Order test2 = (Order)m2.Body;
MessageBox.Show (test2.SSN);

VB.Net Code
--------------
Dim myMessageQueue As MessageQueue = New MessageQueue(g_ strInputQueue)
CType(myMessage Queue.Formatter , XmlMessageForma tter).TargetTyp es = (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(myNewMess age.Body, Order)

Does anyone have any ideas?
Sep 12 '05 #1
1 4440
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.Messagin g.MessageQueue myInputQueue = new
System.Messagin g.MessageQueue( @".\Private$\In putQueue");
((XmlMessageFor matter)myInputQ ueue.Formatter) .TargetTypes = new
Type[]{typeof(Order)} ;

Order test1 = new Order();
test1.intID = "123";
System.Messagin g.Message m1 = new System.Messagin g.Message(test1 );
myInputQueue.Se nd(m1);

System.Messagin g.Message m2 = myInputQueue.Re ceive();
Order test2 = (Order)m2.Body;
MessageBox.Show (test2.SSN);

VB.Net Code
--------------
Dim myMessageQueue As MessageQueue = New MessageQueue(g_ strInputQueue)
CType(myMessage Queue.Formatter , XmlMessageForma tter).TargetTyp es = (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(myNewMess age.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
8002
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 another program. However, when I attempt to Send a message from an ASP.NET VB page, I get "One or more of the passed properties are invalid." I have tried different combinations of the non-transactional Send() with no success. My Windows\Temp...
0
4074
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 = new Message(); msg.AppSpecific = msgCode; msg.Body = msgData;
3
4365
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 are marked with the compiler-attribute (see also code-snippet at the end of the message). It is no problem to serialize a instance of class C, but I got the following error-message if I try to serialize a instance of class D: An unhandled...
1
2692
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 SoapFormatter. The following program gets the exception: "The data at the root level is invalid. Line 55, position -460." This code works fine if I use a BinaryFormatter instead of a SoapFormatter. Any ideas? Here is a test program:
2
2428
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 MSDN example. The CODE is BELOW this lines. If you see something wrong or missing please answer. Class declaration:
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." C# Code ----------- System.Messaging.MessageQueue myInputQueue = new System.Messaging.MessageQueue(@".\Private$\InputQueue"); ((XmlMessageFormatter)myInputQueue.Formatter).TargetTypes = new Type{typeof(Order)};
1
1367
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
6278
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'. On the other hand I have a C# application that reads the same message queue and it expects the body format to be: '<?xml version="1.0"? >..<string>sample</string>'
2
12159
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. --------- <?xml version=""1.0"" encoding=""utf-8""?><DATA><FIELD1>CHIZL</FIELD1><FIELD2>DA MAN</FIELD2></DATA> --------- Methods
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10412
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2909
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.