Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6623417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:31:49+00:00 2026-05-25T21:31:49+00:00

I have a C# Program that is attempting to send to my own local

  • 0

I have a C# Program that is attempting to send to my own local Windows message queue. I have installed message queue and out of desperation gave all access rights to “Everyone” on both the Message Queue itself and the Public queue that I’m trying to write to. I have a form which has two text boxes and two buttons. One pair for sending and another pair for receiving. I click send and get no errors, it can detect that there is in fact a message queue of that name. But the send method seems to go off without actually getting it into the queue. Thanks for any help! Here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Messaging;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
    public MessageQueue myNewPublicQueue;
    private static object lockObject = new object();
    /// <summary>
    /// 
    /// </summary>
    public Form1()
    {
        InitializeComponent();
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void buttoSend_Click(object sender, EventArgs e)
    {
        if (MessageQueue.Exists(@".\queuename"))
        {
            myNewPublicQueue = new System.Messaging.MessageQueue(@".\queuename");
            System.Messaging.Message mm = new System.Messaging.Message();
            mm.Body = textBoxSend.Text;
            mm.Label = "First Test Message";
            myNewPublicQueue.Send(mm);

        }

    }

    private void buttonGet_Click(object sender, EventArgs e)
    {
        myNewPublicQueue.ReceiveCompleted += new          ReceiveCompletedEventHandler(queue_ReceiveCompleted);

        // Start listening.
        myNewPublicQueue.BeginReceive();

    }
    private void queue_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e)
    {


        lock (lockObject)
        {
            // The message is plain text.
            string text = (string)e.Message.Body;
            Console.WriteLine("Message received: " + text);
            textBoxGet.Text = text;
        }

        // Listen for the next message.
        myNewPublicQueue.BeginReceive();
    }
    public enum MessageType
    {
        MESSAGE_TYPE_PLAIN_TEXT = 0,
        MESSAGE_TYPE_HELLO_WORLD = 1
    };

    private void Form1_Load(object sender, EventArgs e)
    {

    }





    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:31:50+00:00Added an answer on May 25, 2026 at 9:31 pm

    When you call the MessageQueue.Send() method, check the Outgoing Queues folder in Message Queueing. You should see a temporary queue has been set up (note, this will only happen if the destination queue is on another machine to the sending machine). Check that queue and you should see your message in it. This means that you have addressed the queue incorrectly in your code.

    Try this: create a private queue and address it using the format FORMATNAME:DIRECT=OS:<server name>\PRIVATE$\<queue name>. From your question it sounds like you really do not need to use public queues.

    Also, don’t bother checking if the queue exists unless you are intending to handle when it doesn’t (for example by raising an exception or creating it programatically).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that spits out both standard error and standard out, and
I have a program that creates a Windows user account using the NetUserAdd() API
I have a program that spits out an Excel workbook in Excel 2003 XML
I have a program that I need to run under *nix and windows. because
I have a program that crashes (attempting to read a bad memory address) while
We have a fairly simple program that's used for creating backups. I'm attempting to
I am new to WINAPI and have figured out how to send a message
I'm currently attempting to write my own program that mirrors the pmap command, specifically
I have been attempting to write a program that will determine if a number
I have program that has a variable that should never change. However, somehow, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.