[RESOLVED] Adding a Reference to a Library class in VB Net (Foundation)
I have added a reference to System.Drawing in my library class and it will now accept a System.Drawing.Point object in my code, but it will not accept a System.Drawing.Color object, nor can I find another place that I might need to add to my References. When I do this I get a BC30002 - Type System.Drawing.Color is not defined error. How do I deal with this error? Thanks.
Re: Adding a Reference to a Library class in VB Net (Foundation)
Is your project targeting .NET Framework or .NET Core and which version? Note that .NET 5.0 is .NET Core. EXACTLY what steps did you follow to add the reference and did you also import the namespace?
Re: Adding a Reference to a Library class in VB Net (Foundation)
I created the library using Version 16.9.4 as a .NET Framewok Library class. I am now using version 16.9.5. To add the Reference, I clicked on References in Solution Explorer and a window appeared that showed a long list of possible references. I found System.Drawing in this list, clicked on the box opposite this and closed the window. I checked that System.Drawing appeared in the list of references for the application. I have also looked at Project->add a reference, and the same list appears, with the box checked. I have Imports System.Drawing at the head on my code for this class.
1 Attachment(s)
Re: Adding a Reference to a Library class in VB Net (Foundation)
Quote:
Originally Posted by
KeithMcCloy
I created the library using Version 16.9.4 as a .NET Framewok Library class. I am now using version 16.9.5. To add the Reference, I clicked on References in Solution Explorer and a window appeared that showed a long list of possible references. I found System.Drawing in this list, clicked on the box opposite this and closed the window. I checked that System.Drawing appeared in the list of references for the application. I have also looked at Project->add a reference, and the same list appears, with the box checked. I have Imports System.Drawing at the head on my code for this class.
That all sounds in order. I just did the same thing and and it all worked for me.
Attachment 181439
Re: Adding a Reference to a Library class in VB Net (Foundation)
Quote:
Originally Posted by
KeithMcCloy
When I do this I get a BC30002 - Type System.Drawing.Color is not defined error. How do I deal with this error? Thanks.
You say that you have imported the namespace but the error message is specifying the fully-qualified name. The whole point of importing the namespace is so that you don't have to qualify the name. Either import the namespace and use the type name unqualified or don't import the namespace and qualify the type name. The System namespace is imported by default at the project level, so you never have to include that in the qualifier. The only reason to break these rules is generally if you need to disambiguate multiple types with the same name, but that is something you should avoid in the first place if you possibly can.
Re: Adding a Reference to a Library class in VB Net (Foundation)
Aha!!, Now I am starting to understand some of this stuff. Followed your advice, JMc and it got rid of my error, Thank You very much:wave: