Skip to content

Additional Control.Invoke overloads break Visual Basic Code #10217

@KlausLoeffelmann

Description

@KlausLoeffelmann

.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.

Metadata

Metadata

Labels

📖 documentation: breakingplease open a breaking change issue https://github.com/dotnet/docs/issues/new?assignees=gewarren💥 regression-releaseRegression from a public releasearea-VisualBasicpriority-2Work that is important, but not critical for the release

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions