简体   繁体   English

使用不起作用的 Visual Studio 2019 自动导入

[英]Auto import usings not working Visual Studio 2019

I have the following selective problem with VS 2019 and IntelliSense.我对 VS 2019 和 IntelliSense 有以下选择性问题。

When I start typing a class name which's namespace is not imported yet, IntelliSense suggests it in the Autocomplete column.当我开始键入名称空间尚未导入的类名称时,IntelliSense 会在“自动完成”列中建议它。 Once I press tab instead of completing the name and importing the using directives it autocompletes the whole path eg:一旦我按tab而不是完成名称并导入 using 指令,它会自动完成整个路径,例如:

Typing ' UserView... ' -> App.Web.Areas.Users.ViewModels.UserViewModel键入“ UserView... ”-> App.Web.Areas.Users.ViewModels.UserViewModel

instead of importing -> using App.Web.Areas.Users.ViewModels;而不是导入 -> using App.Web.Areas.Users.ViewModels; and completing the typing to just UserViewModel并完成输入到UserViewModel

But if I write the whole class name and then press Ctrl + .但是,如果我写下整个班级名称,然后按Ctrl + . , then IntelliSense imports the using directive. ,然后 IntelliSense 导入 using 指令。

Do someone know which setting triggers this behaviour?有人知道哪个设置会触发这种行为吗?

Actually, I did not face the same issue on my PC.实际上,我在 PC 上没有遇到同样的问题。

My Visual Studio 2019 version is 16.7.5 without any other third party vs extensions and I used Newtonsoft.Json.dll .我的Visual Studio 2019版本是16.7.5没有任何其他第三方 vs 扩展,我使用了Newtonsoft.Json.dll

Actually , you should enable the option Show items from unimported namespaces and it will import using Newtonsoft.Json;实际上,您应该启用Show items from unimported namespaces选项,它将using Newtonsoft.Json;导入using Newtonsoft.Json; automatically when you use TAB to complete the code.当您使用 TAB 完成代码时自动完成。

In my side , I typed json and then use TAB to complete the class JsonArrayAttribute .在我这边,我输入json ,然后使用 TAB 来完成JsonArrayAttribute类。 And I did not face the issue as you described.我没有遇到你描述的问题。

在此处输入图片说明

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. 1)如果您的VS2019不是最新版本,请更新到最新版本,新版本会增加最新最全的功能。

2) disable any third party vs installed extensions under Extensions --> Manage Extensions in case you have installed some extensions which caused that. 2)Extensions --> Manage Extensions下禁用任何第三方与已安装的扩展,以防您安装了一些导致该问题的扩展。

3) reset vs settings under Tools --> Import and Export Settings --> Reset all settings 3)工具下重置vs设置-->导入和导出设置-->重置所有设置

4) after that, close VS, delete .vs hidden folder under your solution folder, bin and obj folder. 4)之后,关闭VS,删除解决方案文件夹下的.vs隐藏文件夹, binobj文件夹。 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.此外,如果我误解了您的问题,请指出并提供任何详细信息来描述问题,以帮助我们快速排除故障。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM