O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Send a Custom Message Object Through Message Queuing

Problem

You want to send a custom object to another application via a message queue.

Solution

Create a serializable class that has a zero-argument constructor and includes no read-only properties. Wrap an instance of this class in a Message object and pass the Message object to the MessageQueue.Send method.

Discussion

Message queues accept simple text messages and custom .NET objects. In order to use a custom object, it must satisfy three criteria:

  • The class must have a public constructor with no arguments. .NET uses this constructor to re-create the object when the message is received.

  • The class must be marked with the Serializable attribute.

  • All class properties must be readable and writable. Read-only ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required