Visual Basic

BC30002 Visual Basic And VB Net Type Is Not Defined

BC30002, “Type is not defined”, means the Visual Basic .NET compiler cannot resolve a type used in your code. To fix it, check the type name, its namespace and accessibility, then verify the required project reference, assembly or NuGet package. An Imports statement can shorten.

Which licences fit your PC setup?

Prices are an AUD snapshot, not a live quote. Confirm variant and total on the listing.

What BC30002 tells you about your code

A type is a definition such as a class, structure, interface or enumeration. When a declaration names a type the compiler cannot find, the project cannot compile. The useful part of the error message is the specific type name: start there rather than changing unrelated project settings.

For example, if Dim reader As StreamReader fails, the compiler needs to resolve StreamReader in that location. The problem could be a missing namespace import. If the unknown type belongs to a third-party library, the project may also need a reference to the assembly containing it.

This guide concerns the Visual Basic .NET compiler diagnostic. For related language and development topics, browse the Visual Basic guides.

Fix BC30002 in a practical order

  1. Locate the failing declaration. In Visual Studio, double-click the BC30002 entry in the Error List and record the type name, source file and project. If several errors mention the same missing type, investigate their shared dependency before editing every occurrence.

  2. Check the spelling and declaration. Compare the name with the class definition or library documentation. Search the solution if it is your own type. Confirm that its source file belongs to the project and is included in compilation. A class renamed or removed during refactoring will need its callers updated.

  3. Try the fully qualified type name. For the StreamReader example, change the declaration to Dim reader As System.IO.StreamReader. If that resolves the error, the compiler can already access the type; the short name was the issue. You can retain the qualified name or add Imports System.IO at the top of the file, after any Option statements and before declarations.

  4. Check references in the project that reports the error. A library being present elsewhere in the solution does not give every project access to it. Add a project reference when the type belongs to another project, an assembly reference for the appropriate DLL, or the documented NuGet package. Use the library documentation to identify which dependency actually contains the type.

  5. Restore existing NuGet dependencies. If the project already declares the package but its files are missing, run package restore and inspect any restore errors. Check the configured package source if a package cannot be downloaded. Microsoft’s package restore documentation explains how restore retrieves declared dependencies; it does not add an undeclared package to your project.

  6. Verify accessibility and framework compatibility. A type must be accessible from the calling code, and its library must support the project’s target framework. Check the declaration, package documentation and build messages. Choose a compatible dependency or plan an appropriate framework change rather than assuming that installing the newest library will fix the problem.

  7. Build again and check the result. Resolve any earlier dependency or compilation errors that remain. If references have changed and the IDE still appears to show old diagnostics, clean and rebuild the solution. Rebuilding cannot create a missing type or repair an incorrect namespace, so use it after correcting the underlying issue.

Understand references, namespaces and Imports

A reference makes an external assembly’s types available to your project. A namespace organises type names. An Imports statement lets your source file use available names without writing their full namespace each time. These serve different purposes.

As Microsoft’s Imports documentation explains, importing a namespace does not replace adding a reference. Repeatedly adding Imports statements will not help when the required assembly is absent.

Also, a package name, assembly name and namespace need not match. Copy the namespace from the type’s documentation or declaration instead of guessing it from a DLL filename.

Check the root namespace in your own libraries

Visual Basic projects have a root namespace that affects the names of declared types. For example, with a root namespace of AccountsApp, a Customer class declared inside Namespace Models normally has the full name AccountsApp.Models.Customer. Code in another project must use or import the appropriate namespace as well as reference the library.

If a local namespace hides a framework namespace, a reference such as Global.System.IO.StreamReader can start name resolution at the outermost namespace. See Microsoft’s namespace guidance for the root namespace and Global rules.

Check access before changing a declaration

Finding a type in the solution does not guarantee that the failing code can access it. A Friend type is available within its assembly; a Private nested type has more restricted access. If another assembly needs the type, review whether it should be Public or whether the calling code should use an existing public interface.

Change access deliberately. Exposing an internal implementation merely to remove a compiler error can create an unintended dependency between projects.

Use Visual Studio suggestions with the dependency in mind

IntelliSense and Quick Actions may suggest a namespace import, qualified name or reference. Check that a suggestion points to the intended type, especially when several libraries contain classes with similar names. If the reference itself has a warning, investigate that warning before changing the code.

If the error started after copying a tutorial, compare its project type, dependencies and target framework with yours. Readers practising these concepts can use the guide on how to learn Visual Basic to structure their study. If choosing development tools is a separate concern, see how much Visual Basic costs.

Keep dependency problems from returning

  • Keep package and project references in source control alongside the code that uses them.
  • Document required frameworks and external libraries so another developer can reproduce the build.
  • Review references and namespace changes when moving classes between projects.
  • Check compatibility before updating dependencies, then build the affected projects.

Open the first BC30002 entry now, identify where that type is declared, and check its fully qualified name and reference in the failing project.

Other editions for separate workloads

Other editions for separate workloads; prices in AUD, confirm the total on the listing.

How to check this worked

  1. Open Settings, System, Activation and confirm the edition shown.
  2. Enter the key and run activation; expect a green tick within a minute.
  3. Reboot and re-check activation survives the restart.

FAQ

What else should you know before buying?

What do I need before starting?
Read the requirements and confirm the edition first; the steps assume the machine is compatible.
How do I know the licence is genuine?
Activate on Microsoft's servers and check Settings, System, Activation. A working activation is the test.
Is this a subscription?
Keys sold here are one-time lifetime licences. Microsoft 365 plans are billed by Microsoft instead.
What if the key fails?
Email hi@ms.codes with the order number and a screenshot. Replacement or refund applies within 30 days.

Check who prepared and reviewed this guide

Written by
MS.Codes editorial
Reviewed by
Support team

Last verified: (source review; see test status above).

Recent Post