none
InvaildOperationException "Operation is not valid due to the current state of the object" RRS feed

  • Question

  • I have a screen MaintainProgParameter which is the master for the program parameters. For each parameter I've an image and a short description on the screen. I want to show the according parameter maintenance screen by clicking the image.
    I've used the following code to add a handler to the left mouse button down event.
    The event is raised like expected but the line "Application.ShowMaintainProductGroup" throws the InvalidOperationException mentioned in the title.

    Private Sub MaintainProgParameter_Activated()
            AddHandler Me.FindControl("Image_ProductGroup").ControlAvailable, _
                (Sub(sender, e)
                     Dim img = CType(e.Control, Image)
                     AddHandler img.MouseLeftButtonDown, AddressOf ProductGroupImageOnClick
                 End Sub)

    End Sub

    Private Sub ProductGroupImageOnClick()
           Application.ShowMaintainProductGroup()
    End Sub

    Hopefully someone can give me a helping hand and explain me, what's wrong with my code.

    Cheers

    Uwe

    Tuesday, August 2, 2011 8:14 PM

All replies

  • Hi Uwe,

    Did you resolve this issue in Lightswitch?

    It looks like I have a similar problem. I get the same error but with the LotFocus event of a textbox. You code looks similar to what I have.

    Thanks !

    Sunday, September 11, 2011 4:05 AM
  • Uwe,

    Your code needs to be:

    Private Sub ProductGroupImageOnClick()
        Me.Details.Dispatcher.BeginInvoke(
            Sub()
                Application.ShowMaintainProductGroup()
            End Sub)
    End Sub


    Yann

    (plus ça change, plus c'est la même chose!)

    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, remember to "Mark as Answer".

    This will help people find the answers that they're looking for more quickly.


    Sunday, September 11, 2011 6:18 AM
    Moderator