简体   繁体   中英

System.Drawing does not exist?

I'm trying to create a validation image using class library in asp.net, but that is not the question.

Anyway, my question is... well... system.drawing does not exist so I cant use "bitmap". From similar questions, people tell to add reference. But I already did that, restarted my computer etc. It doesn't work.

What can I do besides adding reference? It doesn't work or am I doing it wrong ?

Here is basically what I did:

  • Right click to references, which is under solution,
  • add reference
  • add system.drawing

But still, it does not appear in intellisense or tells me "it does not exist, try adding reference" when I type it manually.

图片

I suspect that you added the System.Drawing reference to the wrong project. Please verify that the Validator.cs file in the project that has the System.Drawing reference.

You can add referrence 'System.Drawing.dll' to your project.

在此输入图像描述

I had the same issue and solved it, click on the project menu, then Add reference, reference manager will open, then click on the assemblies tab, search for System.Drawing and check it then press ok. it will recognize the package or name space.

I stumbled this error even referencing assembly. After thinking i realised that that error produced after adding a class file which is under 'System' folder which i produced on the project folder. That class has ##.System.## namespace as well under the folder. .Net produced error if you have any custom namespace which contains 'System' keyword. Try changing folder name and namespace if u stumbled as well.

Click on the Project tab and then on Add Reference… 在此输入图像描述

Then select System.Drawing or whatever you want.

您应该将.NET Framework版本更改为.NET 4.0

I have also encountered the same problem. I found that a console/class library project cannot add a reference to System.Drawing. When I changed to use a Window Form project, I was able to add a Bitmap with a reference to System.Drawing.

The error is because you have not added any user control to your class library project. Add a user control to your class library project, and the error will vanish.

I had same problem. I was trying to add Reference to System.Drawing.dll via System Explorer, but it didn't help me. Finally, I put cursor on the varialbe of type 'Graphics', clicked Ctrl+. or 'Alt+Enter->Refactoring' and select 'using System.Drawing'. I don't understand why and how, but it solved my problem. 在此输入图像描述

除了添加引用之外,您还需要使用代码文件顶部的using语句导入它:

using System.Drawing;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM