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

Netstandard2.0-windows下System.Drawing.Common抛出PlatformNotSupportedException求助

解决 System.Drawing.Common 平台不支持异常的建议
  • 启用Windows兼容性开关
    在项目的.csproj文件中添加以下配置,强制激活Windows平台的System.Drawing.Common支持:

    <PropertyGroup>
      <UseWindowsForms>true</UseWindowsForms>
      <EnableWindowsCompatibility>true</EnableWindowsCompatibility>
    </PropertyGroup>
    

    该配置需配合你已引用的Microsoft.Windows.Compatibility包使用,确保兼容性包的Windows专属特性被正确加载。

  • 确认目标框架配置
    检查项目文件中目标框架的声明是否准确,完整节点应如下:

    <TargetFramework>netstandard2.0-windows</TargetFramework>
    

    也可以指定具体Windows版本(如netstandard2.0-windows7.0),消除版本兼容性歧义。

  • 切换到WindowsForms专用绘图API(可选)
    若上述配置无效,可直接引用System.Windows.Forms包,在代码中明确使用该程序集下的绘图类型,避免加载跨平台兼容版本的System.Drawing。

  • 检查.NET运行时版本
    用dotnet --info命令查看当前运行时信息,确保使用的是Windows专属的.NET运行时版本,部分.NET 6+跨平台运行时对System.Drawing.Common的限制更严格。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 18:06:04