简体   繁体   English

Visual Studio Code:建议将此文件类型使用“C#”扩展名

[英]Visual Studio Code : The 'C#' extension is recommended for this file type

So I recently installed visual studio code and added the C# available extensions.所以我最近安装了 Visual Studio 代码并添加了 C# 可用扩展。 I also installed the Unity Debugger but it won't work because "it depends on an unknown 'ms-vscode.csharp' extension", I tried searching for this 'ms-vscode.csharp'in the extensions bar but found nothing.我还安装了 Unity 调试器,但它不起作用,因为“它依赖于未知的 'ms-vscode.csharp' 扩展”,我尝试在扩展栏中搜索这个 'ms-vscode.csharp',但什么也没找到。 whenever i open a C# file from Unity or from any folder it recommends me to install that uknown C# extensions.每当我从 Unity 或任何文件夹打开 C# 文件时,它建议我安装那个未知的 C# 扩展。 what can i do please?请问我该怎么办? here is a picture of the message:这是消息的图片:

在此处输入图像描述

To manually install the correct c# extension, do the following:要手动安装正确的 c# 扩展,请执行以下操作:

  • Uninstall existing vscode C# plugin卸载现有的 vscode C# 插件
  • Close vscode关闭 vscode
  • Download the vsix 1.21.12 from here 从这里下载 vsix 1.21.12
  • Open a command line in the folder where the vsix is.在 vsix 所在的文件夹中打开命令行。
  • Type: code --install-extension .\\csharp-1.21.12.vsix类型: code --install-extension .\\csharp-1.21.12.vsix

You should see:你应该看到:

Installing extensions...
Extension 'csharp-1.21.12.vsix' was successfully installed.

Open VSCode and in the C# output window, you will see:打开 VSCode 并在 C# 输出窗口中,您将看到:

Installing C# dependencies...
Platform: win32, x86_64

Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)' (32544 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'

Errors should now have gone away.错误现在应该已经消失了。

That was a mistake by Microsoft.那是微软的错误。 I just spent hours to solve the problem and noticed that actually the name of the plugin was recently changed, leading to the error.我只是花了几个小时来解决问题,并注意到实际上插件的名称最近已更改,导致错误。 We can fix it by manually downloading a previous version of the plugin.我们可以通过手动下载插件的先前版本来修复它。 Link: https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp&ssr=false#review-details链接: https : //marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp&ssr=false#review-details

I don't do Unity development, but this may help: https://code.visualstudio.com/docs/other/unity我不做 Unity 开发,但这可能会有所帮助: https : //code.visualstudio.com/docs/other/unity

Keep in mind that VSCode is only going to be an editor for your project files.请记住,VSCode 只会成为您项目文件的编辑器。

(Can't comment, apologies for the brief answer) (无法评论,对简短回答表示歉意)

I delete [.vscode\\extensions] , swith to 1.21.1/February 2018 and then update to 1.42.1 .我删除[.vscode\\extensions] ,切换到1.21.1/February 2018然后更新到1.42.1 It finally works fine!它终于正常工作了! Maybe System setup doesn't have the problem.也许系统设置没有问题。 It only occurs on User setup.它只发生在用户设置上。

That error happens because microsoft changed marketplace publisher from ms-vscode to ms-dotnettools.发生该错误是因为微软将市场发布者从 ms-vscode 更改为 ms-dotnettools。 Mentioned here on github.在 github 上提到这里 You can just install the version v1.21.18 and that should solve it.您只需安装 v1.21.18 版本即可解决问题。

VsCode 版本选择

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

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