How to use enableNotification method in MSMQ

  • 12 years ago

     

    I am using MSMQ-3 on my local machine. I am using enableNotification method to notify me when a message comes in the queue. But i am getting error message while using enableNotification. The message comes is "Access is denied" (error no. -1072824283). I am getting the message in the following line

     Dim evnt As MSMQ.MSMQEvent
                evnt = New MSMQ.MSMQEvent
                vMyQSend.EnableNotification(evnt)

     

    anybody please help me.
  • 12 years ago

    Read this document carefully
    http://msdn.microsoft.com/en-us/library/ms711398(VS.85).aspx

    Be careful that,

    1. Declare the MSMQEvent object and the MSMQQueue object globally 
    2. If Opening the watching queue for send access, then don't use new keyword in MSMQEvent object but if Opening the watching queue for receive access then must use the new keyword
    3. Be careful that if you are Opening the watching queue for send accessand using the new keyword then the Error "Access is denied" comes.

    The sample exampe is

     Private WithEvents oEvent As MSMQ.MSMQEvent
     Private myQWatch As MSMQ.MSMQQueue

    Public Sub.............
          
             Dim myQWatchInfo As New MSMQ.MSMQQueueInfo
            myQWatchInfo.PathName = ".\Private$\WatchQueue"
            myQWatch = myQWatchInfo.Open(MSMQ.MQACCESS.MQ_RECEIVE_ACCESS,_ MSMQ.MQSHARE.MQ_DENY_NONE)

            oEvent = New MSMQ.MSMQEvent
            myQWatch.EnableNotification(oEvent)
            MsgBox("EnableNotification is now Running")

    End Sub

     Shahid Noor

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan