Beispiel #1
0
    public static void Main()
    {
        MessageQueue myQueue = new MessageQueue(".\\myQueue");

        // Set the formatter to indicate body contains an Order.
        myQueue.Formatter = new BinaryMessageFormatter();
        var a = new BinaryMessageFormatter().GetTest();

        //test case
        var b = new BinaryMessageFormatter();
        var c = b.GetTest();

        // Receive and format the message.
        System.Messaging.Message myMessage = myQueue.Receive();
        Bitmap myImage = (Bitmap)myMessage.Body;

        // This will be saved in the \bin\debug or \bin\retail folder.
        myImage.Save("ReceivedImage.bmp");

        byte[]          buffer    = new byte[] { 1, 2, 3 };
        MemoryStream    memStream = new MemoryStream(buffer);
        BinaryFormatter bf        = new BinaryFormatter(null, new StreamingContext(StreamingContextStates.All));
        DataTable       dt        = (DataTable)bf.Deserialize(memStream);
    }