dotnet / dotnet/wpf

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

Open
#10,255 1 comment 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Error-BC30311-when-importing-systemDraw/10821383)._

---
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](https://aka.ms/dc/image?name=Bf9939bbab2384820a56e5a75108fb0e6638713530193418534_TestBC30311.gif&tid=f9939bbab2384820a56e5a75108fb0e6638713530193418534)

A simplified test program is available here.

[TestUserControl.zip](https://aka.ms/dc/file?name=B0b523331cff04705b431f6a70e8500c1638713533040807050_TestUserControl.zip&tid=0b523331cff04705b431f6a70e8500c1638713533040807050)

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.