Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't reference system.drawing.dll

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

"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"

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:

rightclick project -> add reference -> select COM ->find the 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"

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
    }
like image 227
KristianMedK Avatar asked Jan 31 '13 14:01

KristianMedK


People also ask

How do you add references to System drawing DLL?

Kartiikeya, in the Solution Explorer tab, 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.

What is System drawing DLL?

System. Drawing. dll is a Windows DLL file. DLL is the abbreviation for Dynamic Link Library. DLL files are needed by programs or web browser extensions, because they contain program code, data, and resources.


1 Answers

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

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

like image 158
Daniel Kelley Avatar answered Sep 18 '22 01:09

Daniel Kelley