BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2005+

Visual Studio Namespace Resolution

Sometimes when coding you will type the name of a class or structure that is not recognised because the name is not fully qualified and the appropriate using directive is missing. This can be a particular problem when copying sample code from web sites.

Resolving Namespaces

The Visual Studio code editor provides a handy shortcut for finding the namespace associated with a class. This shortcut is available when a class name is entered that is invalid because it is neither fully qualified nor has an appropriate "using" statement. In this situation, you can right-click the offending class and open the Resolve submenu in the context-sensitive menu that appears.

Visual Studio Resolve Menu

The first option in the Resolve menu shows the using directive that must be added to the code in order to make the selected class available. If you click this option, the using directive is added at the top of the code. If you are using visual Studio 2008, you can then use the Organize Usings command to sort the list of using directives without scrolling to the top of your code.

If you do not wish to add the using directive because this is the only reference to any class from the related namespace, you may decide to select the second option from the Resolve menu. This modifies the class name so that it is fully qualified.

NB: The Resolve menu only appears if the class in question is part of the current project or exists within a referenced assembly.

23 July 2008