Results 1 to 6 of 6

Thread: [RESOLVED] Adding a Reference to a Library class in VB Net (Foundation)

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Location
    Denmark
    Posts
    14

    Resolved [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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Location
    Denmark
    Posts
    14

    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.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Adding a Reference to a Library class in VB Net (Foundation)

    Quote Originally Posted by KeithMcCloy View Post
    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.

    Name:  System.Drawing.jpg
Views: 1159
Size:  40.0 KB
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Adding a Reference to a Library class in VB Net (Foundation)

    Quote Originally Posted by KeithMcCloy View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Location
    Denmark
    Posts
    14

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width