Skip to content
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

Error BC30311 when importing system.Drawing into a user control. #10255

Open
vsfeedback opened this issue Jan 10, 2025 · 1 comment
Open

Error BC30311 when importing system.Drawing into a user control. #10255

vsfeedback opened this issue Jan 10, 2025 · 1 comment
Labels
Investigate Requires further investigation by the WPF team.

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


I had developed a user control in WPF with VB and the 4.8 framework that worked perfectly.
By recreating the same user control with .net 9, I noticed many BC30111 error detections.
Ex: Unable to convert a value of type Point to Point.
Unable to convert a value of type Color to Color.

This problem is present when the system.drawing library is imported.
This library was imported to use the ToolboxBitmap property.

You can see this error behavior on the illustration.

TestBC30311.gif

A simplified test program is available here.

TestUserControl.zip

Visual Studio 2022 Version 17.12.1
.Net 9
WPF Program in VB


Original Comments

Nicole Hu [MSFT] on 2/1/2025, 10:42 AM:

We have converted this feedback item to a problem. This change was done to better reflect the feedback’s nature. It will allow other developers to easily find it and engage on it.

jacky.perpete on 2/1/2025, 00:18 PM:

To avoid the error, you have to remove the import code line of the system.drawing library and add the library reference in the ToolboxBitmap property declaration.

My user control code with framework 4.8 was built this way. The problem was already there.
This is a problem that has existed for several years and has never been corrected.

MC3000Solve.png

Feedback Bot on 2/1/2025, 01:24 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@siagupta0202 siagupta0202 added the Investigate Requires further investigation by the WPF team. label Jan 10, 2025
@miloush
Copy link
Contributor

miloush commented Jan 10, 2025

This seems to be by design. Color and Point types are both in the System.Windows and System.Drawing namespaces. If the solution by jacky.perpete (i.e. removing the using) is not acceptable, you have to specify fully qualified type (such as System.Windows.Media.Color instead of Color).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

3 participants