Sending serialized object through MessageQueue

G

Guest

I'm trying to implement sending an object through messaging, but I receive an
error stating I can't deserialize the object. Any clues as to why.

I have the following:

<Serializable()> Public Class navMessage

dim m_Category as int32
dim m_Id as string

property Category() as int32
Get
return m_Category
end get
set (byval value as int32)
m_Category = value
end set
end property
property MsgId() as string
Get
return m_Id
end get
set (byval value as string)
m_Id = value
end set
end property
end class



Note: .\NavTest queue exists
In the first application I do the following:

dim mq as MessageQueue(".\NavTest")
dim oMsg as new navMessage
oMsg.MsgId = "Test"
oMsg.Category = 100
mq.formatter = new binarymessageformatter
mq.send(oMsg)

In the second application I do the following:
dim mq as MessageQueue(".\NavTest")
dim oMsg as navMessage
oMsg = CType(mq.receive().body, navMessage) **


** this line give me the following error:

Cannot deserialize the message passed as an argument. Cannot recognize the
serialization format.
 
G

Guest

Have you tried setting the Formatter to a BinaryFormatter on the receiving
message queue?

HTH
Dan
 
G

Guest

Dan,

I forgot to that line of code, but yes, I had set the receiving formatter.

I have gotten it to work.

Instead of :

mq.formatter = new binarymessageformatter

I'm doing:

mq.formatter = new xmlmessageformatter(new type() {gettype(Nav.navMessage)})

on both the sending and receiving end.

Now, once I receive the message, I can do:

dim msg as Message
msg = mq.receive()

then:

msg.body.msgid

or:

dim oMsg as navMessage
oMsg = msg.body
oMsg.msgid

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top