469,360 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Sending serialized object through MessageQueue

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.
Jul 21 '05 #1
2 8967
Have you tried setting the Formatter to a BinaryFormatter on the receiving
message queue?

HTH
Dan

"Chuck Marques" wrote:
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.

Jul 21 '05 #2
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

"Dan Kelley" wrote:
Have you tried setting the Formatter to a BinaryFormatter on the receiving
message queue?

HTH
Dan

"Chuck Marques" wrote:
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.

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gabriel Gudenus | last post: by
6 posts views Thread by Jacek | last post: by
3 posts views Thread by Gerhard Swart | last post: by
reply views Thread by Ray Mitchell | last post: by
4 posts views Thread by Risen | last post: by
2 posts views Thread by Chuck Marques | last post: by
9 posts views Thread by Nick Gilbert | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.