- You might have misspelled the name of the namespace that you are trying to import. Without the correct name, the compiler is unable to find the namespace.
- You may have spelled the name correctly, but you do not have the assembly where the namespace resides referenced in your project.
- Namespaces are logical groupings of classes that are contained within assemblies. You can think of an assembly as a .dll or .exe file. When you compile a project in Visual Studio .NET, you are creating an assembly. Assemblies can contain multiple namespaces. In order to import a namespace you must first reference the assembly where the namespace resides. To reference the assembly, from the Project menu click Add Reference. On the .NET tab, select the assembly that contains the namespace that you are trying to import, or Browse to the folder that contains the assembly.
- Check your imports statement to make sure that you have the correct name of the namespace. Keep in mind that the namespace you want to use might be nested in one or more namespaces. For example, the SqlClient namespace is located in the Data namespace. The Data namespace is located in the System namespace. So, to import the SqlClient namespace you would need to use the following Imports statement:
Steps to Reproduce Behavior
- Create a new Visual Basic .NET or Visual Basic 2005 console application.
- In Module1.vb, at the top of the code file, add the following statement:
- To see the error message, move the mouse pointer over the Imports statement for the namespace or build the project. Notice that you will receive the error because you have not referenced the System.Drawing.dll assembly. If you reference this assembly the error message will disappear.
ID do Artigo: 304260 - Última Revisão: 16/06/2009 - Revisão: 1