Use Ctrl + Period to resolve a missing namespace reference

I love Microsoft Intellisense and the fact that it is so helpful. One aspect I like is that it will help you resolve a missing namespace reference. Generally when you add a reference to a namespace and it has not been declared, Microsoft will underline the missing reference in red. When you hover over it you will get an error message saying : “The type or namespace name ‘xxx’ could not be found (are you missing a using directive or an assembly reference?)

 missing reference

 

 

To resolve this problem you have two options, you can right-click the missing reference and choose Resolve.

missing ref 2

You can place a reference to the missing namespace at the top of your class by choosing the using statement or you can place it inline by selecting the full namespace. If you are going to be using this namespace reference in other places within your class then obviously the former is the better choice.

There is another way to create a reference to this missing namespace. When you know the namespace is missing and you have finished typing the initial reference, you can hit Ctrl + . (period) to raise a dialog box helper. From here you can arrow up or down to select and instantiate the namespace reference. This way you do not have to reach for the mouse and break your flow.

missing ref 3

Advertisements

About Ken Cenerelli
I am a Programmer Writer, .NET Developer, Microsoft MVP - Visual Studio and Development Technologies, Public Speaker, Blogger, and Microsoft Azure Nerd. I blog regularly at kencenerelli.wordpress.com and can be found on Twitter via @KenCenerelli.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: