System.Drawing does not exist?

十年热恋 提交于 2020-02-26 11:18:52

问题


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.


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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.




回答5:


Click on the Project tab and then on Add Reference…

Then select System.Drawing or whatever you want.




回答6:


In addition to adding the reference, you will also need to import it using the using statement in the top of your code file:

using System.Drawing;



回答7:


You should change .NET Framework version to .NET 4.0




回答8:


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.




回答9:


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.




回答10:


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.



来源:https://stackoverflow.com/questions/6940612/system-drawing-does-not-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!