-
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
Unable to use ICustomTypeDescriptor in C++/CLI #109950
Comments
C++/CLI compiler doesn't handle default interface method in this case. |
Is there any solution or workaround to fix in my scenario? We have too much usage like this. |
What version of MSVC compiler are you using? There are several updates for type system recently. |
Hello! In .NET 9, ICustomTypeDescriptor includes new members with default implementations, such as: RequireRegisteredTypes Managed C++ does not seamlessly support default interface methods added in newer .NET versions, necessitating the explicit implementation of all interface members, even those with default implementations in .NET languages like C#.
I tried here and worked fine, I hope it helps you. I used C++/CLI support for v143 build tools (Latest). To execute: Do not forget the Main() from cpp |
Hi, @huoyaoyuan The MSVC version is 14.40.33807. |
Hi @JavaScript-Py , I am glad to get a workaround from you. I copied the code and tried to compile my test project, but there are still the same issues:
I have tried to fix it by adding implementations in the C++/CLI class :
That will make the build pass, but I am worried that it might cause the runtime to fail. |
Seems that the latest version of msvc hasn't provide support for default interface method, and you have to provide implementation of the methods.
It should run fine. You can copy the default implementation of the methods from C# source at https://github.com/dotnet/runtime/blob/main/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/ICustomTypeDescriptor.cs . |
Closing; please report back if the work-around of adding the default implementation works. |
Description
I am working on the dotnet 9 migration in our repo.
When I tried to build a managed C++ project, it failed. The error log shows :
It seems it's related to C++/CLI doesn't support the default interface method.
Reproduction Steps
Create a managed C++ project in Visual Studio and fill it with the following codes:
Then, compile the project.
Expected behavior
Build success.
Actual behavior
Build fail.
Regression?
Yes, I can build these code on .net 8
Known Workarounds
No
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: