【问题标题】:Using classes in Class library project在类库项目中使用类
【发布时间】:2021-12-20 15:42:54
【问题描述】:

我创建了一个 .NET 标准类库项目,但是当我尝试使用 System.Drawing 类时,一切都表现得好像它不存在一样。我不能在课堂上使用任何东西。 为什么会发生这种情况以及如何解决?

using System;
using System.Drawing;

namespace Blueberry
{
    public class GameObject
    {
        public void Sprite()
        {
            Image img; //Error: Type Image not found
        }
    }
}

【问题讨论】:

标签: c# class


【解决方案1】:

System.Drawing 是一个仅限 Windows 的组件,因此需要 .NET Framework(或兼容包)。

如果您想使用 .NET Standard,可以将 System.Drawing.Common Nuget 包添加到您的项目中。

【讨论】:

    猜你喜欢
    • 2011-12-22
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-17
    • 2019-11-11
    • 2013-01-17
    • 1970-01-01
    相关资源
    最近更新 更多