Skip to content

Visual Basic late binding failure on COM objects #90541

Closed
@MikeJDeck

Description

@MikeJDeck

Description

When a COM object is used (through an interop assembly) in Visual Basic, late binding can fail in two cases:

  1. If the object has been cast to a plain Object type.
  2. If the object implements more than one interface (e.g. InterfaceA and InterfaceB). If the object is declared as InterfaceA, late binding will fail on a property that is defined on InterfaceB.

This problem shows up in .NET 7 and .NET 8 preview 7. It is a regression from .NET Framework behavior.
The problem does not show up in C# when doing late binding on the dynamic type.

Reproduction Steps

Problem 1 can be shown with Microsoft Excel COM Interop.

The attached Visual Studio solution demonstrates problems 1 and 2. It contains a COM server and .NET test projects. Details are in the README.md file.
ATLTest563.zip

Expected behavior

On the Windows OS, late binding on COM objects works the same as in the .NET Framework.

Actual behavior

Late binding fails under the conditions decribed above (more details in the README.md file).

Regression?

It is a regression from .NET Framework 4.8 (and previous versions of .NET Framework).

It is probably not a regression from previous releases of .NET Core.
Problem 1 has been reported previously in .NET 5.

Known Workarounds

The workaround is to use early (compile-time) binding.
That workaround is fine for new code, but there is a lot of existing late-binding code in .NET Framework written against the Autodesk Inventor API by Inventor customers. We want to provide a seemless upgrade path for the authors of that code.

Configuration

.NET 7, and .NET 8 preview 7.
Windows 10
x64 or x86

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions