InvalidOperationsException (Vb.net)

LoveToCode 161 Reputation points
2021-04-11T10:48:28.457+00:00

I'm dealing with something strange - earlier I was able to list all my data in a list view control using the following code: Now after couple day I get an InvalidOperationsException.

        If wresults.WorkItems.Any Then
            'Dim wref As IEnumerable(Of WorkItemReference)
            LV_WIT.View = View.Details
            For wit = 0 To wresults.WorkItems.Count - 1

                Debug.Print("Work Item id:-    " & wresults.WorkItems(wit).Id)  [This prints well]
                LV_WIT.Items.Add(wresults(wit).Id) 



            Next


        End If
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LoveToCode 161 Reputation points
    2021-04-12T08:41:15.4+00:00

    I figured that there was a overlap of two API's one after the other, which was causing this exception. So once I removed the other declaration it was all back to normal.

     Dim results = Await WClient.QueryByWiqlAsync(Query)
     Dim f = Await WClient.GetWorkItemAsync(11).ConfigureAwait(False) '(this was the problematic declaration as they were under the same thread I believe. Once I removed it, everything was ok
    
    0 comments No comments