You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

System.Drawing中Graphics/Brushes/Bitmap失效,仅PointF正常的问题求助

Hey, let's work through this System.Drawing issue you're facing — it's a super common gotcha, especially with newer .NET versions, so I’ve got a few targeted fixes to try out:

Common Causes & Fixes

1. You’re probably using a .NET version that doesn’t include System.Drawing.Common by default

Starting with .NET 6, System.Drawing.Common was moved out of the core framework (even on Windows). If your project is on .NET Core/.NET 5+, you’ll need to manually add the NuGet package:

  • Right-click your project → Manage NuGet Packages, search for System.Drawing.Common, and install the latest stable version.
  • Or run this command in the Package Manager Console:
    Install-Package System.Drawing.Common
    

2. Double-check your namespace references

Even if PointF works, Graphics, Brushes, and Bitmap rely on the full System.Drawing namespace being imported. Make sure these lines are at the top of your code file:

using System.Drawing;
using System.Drawing.Drawing2D; // Optional, but needed for advanced drawing features

Missing these will make the compiler act like those classes don’t exist.

3. Fixing the empty Reference Manager

An empty Reference Manager usually ties back to project type or framework compatibility:

  • Check your target framework: Right-click the project → Properties → Application → Target Framework. If you’re using a generic .NET 6/7/8 (not the Windows Desktop variant), the Reference Manager will be limited — switch to a Windows-specific framework (like .NET 6 Windows Desktop) or use the NuGet package method above.
  • Refresh your project: Sometimes Visual Studio’s cache glitches. Right-click the project → Unload Project, then right-click again → Reload Project. That often fixes missing references in the manager.

4. Ensure you have the right SDK components installed

For Windows Forms/WPF projects, make sure you’ve got the necessary Windows SDK bits in Visual Studio:

  • Open the Visual Studio Installer → Modify → Under ".NET Desktop Development", check all relevant components (especially Windows Forms SDK).

Quick Troubleshooting Checklist

  1. Uninstall any existing System.Drawing references if they’re present.
  2. Install the System.Drawing.Common NuGet package.
  3. Clean your solution (Build → Clean Solution) then rebuild it (Build → Rebuild Solution).
  4. Restart Visual Studio — cached data can sometimes mess with reference detection.

After going through these steps, Graphics, Brushes, Bitmap, and the Reference Manager should start behaving as expected.

内容的提问来源于stack exchange,提问作者nymda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:48:49