-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visual Basic late binding failure on COM objects #90541
Comments
@MikeJDeck Thanks for this suggestion. I would also like to thank you for an amazing repro sample, it is most appreciated. As noted, we've previously pushed back on several late bound scenarios. This one is slightly different but in the same domain as the others. I can concieve of a potential solution here by consuming the C# I'm going to push this into .NET 9 as something to consider rather than just marking this "by design". We need some more interest and if the community indicates there is that we can consider creating a minor affordance here. |
The look up logic could be updated to inspect the COM instance below: Line 950 in 782aea1
|
@AaronRobinsonMSFT , thanks for looking at this and putting it into .NET 9. Here's a few more details about our business case. In Inventor, we use Visual Basic as something like a scripting language. It is wrapped in a layer that we call iLogic (Inventor Logic). The user only sees their source code and the results of executing the code. We compile their code into DLLs, but these are generally not visible to the user and are not persisted beyond a single session of Inventor. In the Inventor API, a common example of the pattern of late binding on a base object is:
We're trying to figure out how many people are using these in a late-binding way. Our conservative estimate at this time is 100 programmers and 1500 consumers of those programs. In addition, we have customers who are more familiar with programming and write add-ins or standalone executables against the Inventor API. Most of them are probably using C#, but some use Visual Basic and some of those probably have some cases of late binding. |
Description
When a COM object is used (through an interop assembly) in Visual Basic, late binding can fail in two cases:
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
The text was updated successfully, but these errors were encountered: