C# 无法引用 system.drawing.dll

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14628455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 12:29:26  来源:igfitidea点击:

Can't reference system.drawing.dll

c#system.drawingimageresizer

提问by KristianMedK

i'm trying to resize images with ImageResizer, but keep getting a compilation error

我正在尝试使用 ImageResizer 调整图像大小,但不断收到编译错误

"Error 1 The type 'System.Drawing.Bitmap' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing"

“错误 1 ​​类型“System.Drawing.Bitmap”是在未引用的程序集中定义的。您必须添加对程序集“System.Drawing”的引用

Searching for a solution i find several similar questions where the solution is to reference system.drawing.dll to be able to handle images, but when i tried referencing it by:

在寻找解决方案时,我发现了几个类似的问题,其中解决方案是引用 system.drawing.dll 以能够处理图像,但是当我尝试通过以下方式引用它时:

rightclick project -> add reference -> select COM ->find the system.drawing.dll

右键项目->添加引用->选择COM->找到system.drawing.dll

but this gives me another error saying "the activeX type library system.drawing.tlb was exported froma .NET assembly and cannot be added as a reference. Add a reference to the .NET assebly instead"

但这给了我另一个错误,提示“activeX 类型库 system.drawing.tlb 是从 .NET 程序集导出的,无法添加为参考。改为添加对 .NET 程序集的引用”

And this is where i'm left dumbfounded as what to do next.

这就是我对下一步该做什么感到目瞪口呆的地方。

Edit:

编辑:

code where i get the error

我收到错误的代码

public void resizeImage(String originalFile, String thumb)
    {
        ResizeSettings r = new ResizeSettings();
        r.MaxHeight = 200;
        r.MaxWidth = 200;


      ImageBuilder.Current.Build(originalFile, thumb, r);//this is where i get the first error
    }

采纳答案by Daniel Kelley

Add it from the .NET tab, not the COM tab.

从 .NET 选项卡而不是 COM 选项卡添加它。

In the Solution Explorer tab Of Visual Studio, right click on References and select "Add Reference...". Then click Assemblies, Framework, and scroll down until you see System.Drawing. Click the checkbox next to it, then click OK

在 Visual Studio 的“解决方案资源管理器”选项卡中,右键单击“引用”并选择“添加引用...”。然后单击程序集、框架并向下滚动,直到看到 System.Drawing。单击旁边的复选框,然后单击确定