Using MSMQ and ProcessCmdKey appears to be incompatiable RRS feed

  • Question

  • Hello,

    Am using in VS 2010. I have a working program using ProcessCmdKey. I use it to capture various keyboard actions:

    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
    ' capture some key presses, etc.
    End Function

    However, if I add a reference to MSMQ ( after turning it on in "features") and adding the imports statement(Imports System.Messaging), the debugger gives me the red line on ProcessCommandKey:

    The message associated with the redline is:

    Function 'ProcessCommandKey' cannot be declared 'Overrides' because it does not override a function in the base class.

    The 2 suggestions do not fix this issue:

    1) Delete the 'Overrides' specifier.

    2) Replace 'Overrides' with 'Overloads'

    Any suggestions on making ProcessCommandKey and MSMQ both happy?


    Friday, March 15, 2019 5:06 PM

All replies

  • Try removing ‘Imports System.Messaging’ or specify the full names for parameters: ‘ByRef msg As System.Windows.Forms.Message’, etc.

    Friday, March 15, 2019 5:32 PM
  • Thanks for your reply.

    Here is the original code when using 'Imports System.Messaging' (note that this code works)

    DimAs MessageQueue = Nothing

     If Not MessageQueue.Exists(qName) Then
                    Console.WriteLine("creating queue: " & qName)
    End If

    Q = New System.Windows.Forms.Message(qName)

    However, if I attempt to use the following, I get multiple compile errors:

    Dim Q As System.Windows.Forms.Message = Nothing
                ' make q if not exist
    If Not System.Windows.Forms.Message.Exists(queName) Then
                Console.WriteLine("creating queue: " & queName)
    End If

    Q = New System.Windows.Forms.Message(qName)

    Any suggestions on moving forward? Thanks again!

    And here is what I tried as per your suggestion:

    Q = New System.Windows.Forms.Message(qName)

    Wednesday, March 20, 2019 3:10 PM
  • Use System.Windows.Forms.Message when you need one kind of messages, and System.Messaging.Message when you need another kind of messages, and System.Messaging.MessageQueue when you need message queue.

    Wednesday, March 20, 2019 5:25 PM