Auto import usings not working Visual Studio 2019

8k Views Asked by At

I have the following selective problem with VS 2019 and IntelliSense.

When I start typing a class name which's namespace is not imported yet, IntelliSense suggests it in the Autocomplete column. Once I press tab instead of completing the name and importing the using directives it autocompletes the whole path e.g.:

Typing 'UserView...' -> App.Web.Areas.Users.ViewModels.UserViewModel

instead of importing -> using App.Web.Areas.Users.ViewModels; and completing the typing to just UserViewModel

But if I write the whole class name and then press Ctrl + ., then IntelliSense imports the using directive.

Do someone know which setting triggers this behaviour?

1

There are 1 best solutions below

3
On BEST ANSWER

Actually, I did not face the same issue on my PC.

My Visual Studio 2019 version is 16.7.5 without any other third party vs extensions and I used Newtonsoft.Json.dll.

Actually, you should enable the option Show items from unimported namespaces and it will import using Newtonsoft.Json; automatically when you use TAB to complete the code.

In my side, I typed json and then use TAB to complete the class JsonArrayAttribute. And I did not face the issue as you described.

enter image description here

So I am confused that why this happened in your side.

Or you could try the following steps:

1) If your VS2019 is not the latest version, please update it to the latest version and the new version will add the latest, most comprehensive features.

2) disable any third party vs installed extensions under Extensions-->Manage Extensions in case you have installed some extensions which caused that.

3) reset vs settings under Tools-->Import and Export Settings-->Reset all settings

4) after that, close VS, delete .vs hidden folder under your solution folder, bin and obj folder. Then, restart your project to test again.

Besides, if I misunderstood your issue, please point out and provide any detailed info to describe the issue to help us troubleshoot it quickly.