Community discussion forum

How to use enableNotification method in MSMQ

Tags: Jordan
  • 4 months 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.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 3 months 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).