Skip to content

Additional Control.Invoke overloads break Visual Basic Code #10217

Open

Description

.NET version

.NET 6+

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

.NET 3.1

Issue description

The new overloads we introduced for Control.Invoke breaks Visual Basic code.
This used to be OK before:

If String.IsNullOrEmpty(Me.Text) Then
>>  Me.Invoke(Sub()
>>      myDataGridForm.BindableDataGridView.DataSource = myDataSource
>>  End Sub)
    Return
End If

This does no longer work.

image

The reason is that the Visual Basic compiler automatically creates the expected type for a Lambda. So here, the identifier names represents the actual types, which the compiler automatically generates.

image

To correct this, we need to rewrite it and help the compiler to create the correct type like this (as one solution):

If String.IsNullOrEmpty(Me.Text) Then
    Me.Invoke(New Action(
        Sub()
            myDataGrid.DataSource = myDataSource
        End Sub))
    Return
End If

Steps to reproduce

Just try the above discussed code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

📖 documentation: breakingA change in behavior that could be breaking for applications. Needs to be documented.💥 regression-releaseRegression from a public releasePriority:2Work that is important, but not critical for the releasearea-VisualBasic

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions