Visual Studio 2012 中的普通 C# 编辑器(无智能感知、无缩进、无代码高亮)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11988077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 19:58:52  来源:igfitidea点击:

Plain C# Editor in Visual Studio 2012 (No intellisense, no indentation, no code highlighting)

c#.netvisual-studiovisual-studio-2012

提问by Escobar5

I just installed visual studio 2012 in my machine, I previously had visual studio 2012 RC which I uninstalled before. The installation was successful, but after I open a project the C# editor is not working, is just like a plain text editor like this:

我刚刚在我的机器上安装了visual studio 2012,我之前有我之前卸载过的visual studio 2012 RC。安装成功,但在我打开一个项目后,C# 编辑器不起作用,就像这样的纯文本编辑器:

C# editor

C# 编辑器

I've tried repairing it, uninstalling it completely and then installing again, but no success.

我试过修复它,完全卸载它,然后再次安装,但没有成功。

Anyone have an idea?

有人有想法吗?

I don't know if it is related, but I'm also getting this error sometimeswhen creating a new project or when opening an existing one:

我不知道它是否相关,但有时在创建新项目或打开现有项目时我也会收到此错误:

Vs error

VS 误差

Thanks in advance

提前致谢

采纳答案by Oleg Tkachenko

I'm pretty sure the error about ManagedObjectFactory is related to the symptoms you are describing. This error indicates your Visual Studio installation (particularly the C# language service) is corrupted. Most likely this is caused by some setup issue, which we are currently working to identify.

我很确定有关 ManagedObjectFactory 的错误与您描述的症状有关。此错误表明您的 Visual Studio 安装(尤其是 C# 语言服务)已损坏。这很可能是由一些设置问题引起的,我们目前正在努力确定。

I had a chance to investigate this error and found that one of our interop assemblies is unexpectedly installed into the GAC, while it shouldn't be. It's installed into the GAC by Windows installer, which indicates this is a setup issue. The fix is to uninstall it from the GAC, but because it's installed by Windows installer, it's more than just "gacutil /u". You need to follow the procedure described in KB873195to remove it from the GAC:

我有机会调查这个错误,发现我们的互操作程序集之一意外安装到 GAC 中,而它不应该安装。它由 Windows 安装程序安装到 GAC 中,这表明这是一个设置问题。修复方法是从 GAC 卸载它,但因为它是由 Windows 安装程序安装的,所以它不仅仅是“gacutil /u”。您需要按照KB873195 中描述的步骤将其从 GAC 中删除:

  1. Delete a value corresponding to the “Microsoft.VisualStudio.CSharp.Services.Language.Interop” assembly from the "HKLM\SOFTWARE\Classes\Installer\Assemblies\Global\". Note the "Interop" part because there is also Microsoft.VisualStudio.CSharp.Services.Language assembly, which must be in the GAC.
  2. Start "VS2012 x86 Native Tools Command Prompt" and run "gacutil /u Microsoft.VisualStudio.CSharp.Services.Language.Interop".
  1. 删除与“Microsoft.VisualStudio.CSharp.Services.Language. “HKLM\SOFTWARE\Classes\Installer\Assemblies\Global\”中的互操作”程序集。注意“Interop”部分,因为还有 Microsoft.VisualStudio.CSharp.Services.Language 程序集,它必须在 GAC 中。
  2. 启动“VS2012 x86 Native Tools Command Prompt”并运行“gacutil /u Microsoft.VisualStudio.CSharp.Services.Language.Interop”。

Disclaimer: I'm a dev on the Visual Studio C# IDE team.

免责声明:我是 Visual Studio C# IDE 团队的开发人员。

回答by reggie

It may be that some of the settings are disabled in visual studio. Check the following settings:

可能是 Visual Studio 中禁用了某些设置。检查以下设置:

Tools->Options->Text Editor->C#->General->Auto list members
Tools->Options->Text Editor->C#->General->Parameter information

EDIT:

编辑:

Also check

还要检查

Tools->Options->Text Editor->C#->Intellisense->
Show completion list after a character is typed

Here is an article on ScottGu's blogwhich can be helpful:D

这是ScottGu 博客上的一篇文章,可能会有所帮助:D

Second EDIT:

第二次编辑:

There is one more article on ScottGu's blog titled No Intellisense with VS 2010 RC (and how to fix it). Let me know if that helps. The patch is available here.

ScottGu 的博客上还有一篇题为No Intellisense with VS 2010 RC (and how to fix it) 的文章。如果这有帮助,请告诉我。该补丁可在此处获得

Third Edit:

第三次编辑:

Tools –> Import and Export Settings ->  Reset all Settings

You can backup the old settings if you want. This solutionis for visual studio 2012. I believe this should work

如果需要,您可以备份旧设置。此解决方案适用于 Visual Studio 2012。我相信这应该可行

Fourth Edit: Instead of changing it for only C#, change it for all the languages

第四次编辑:不是仅针对 C# 更改它,而是针对所有语言更改它

Tools > Options > Text Editor > All Languages

In general, ensure that the checkboxes in the Statement Completion section are actively checked (not grayed out). There is a possibility of having a blue square rather than a tick mark. As the tick boxes are 3 state, the square meant that "Partial Selection" was in effect. Once the tick mark is in effect, restart Visual Studio and try it again.

通常,确保主动选中 Statement Completion 部分中的复选框(未变灰)。有可能是蓝色方块而不是刻度线。由于勾选框是 3 个状态,所以正方形意味着“部分选择”有效。勾号生效后,重新启动 Visual Studio 并重试。

Final Edit:

最终编辑:

Looks like the installation is missing some files. I would advise you to download a fresh copy of the software and install it from scratch, with the default settings active.

看起来安装缺少一些文件。我建议您下载软件的新副本并从头开始安装,默认设置处于活动状态。

回答by PhonicUK

Try deleting:

尝试删除:

  • %appdata%\Roaming\Microsoft\Microsoft Visual Studio
  • %appdata%\Roaming\Microsoft\VisualStudio
  • %appdata%\Local\Microsoft\VisualStudio
  • %appdata%\Roaming\Microsoft\Microsoft Visual Studio
  • %appdata%\Roaming\Microsoft\VisualStudio
  • %appdata%\Local\Microsoft\VisualStudio

This should erase all of your visual studio settings (from all versions) and restore it to default, in case some old settings were left behind by the RC that the RTM doesn't like.

这应该会清除所有 Visual Studio 设置(从所有版本)并将其恢复为默认值,以防 RTM 不喜欢的 RC 遗留了一些旧设置。

Edit:

编辑:

Also you want to remove

你也想删除

  • My Documents/Visual Studio 2012/Settings
  • 我的文档/Visual Studio 2012/设置

回答by Rus

I just had the same issue as you and followed the instructions I found here.

我和你遇到了同样的问题,并按照我在这里找到的说明进行了操作。

The part I found that worked was:

我发现有效的部分是:

  1. Try running devenv /Resetsettings in Command Prompt to eliminate the cause of corrupted settings.
  2. Try running devenv /ResetSkipPkgs in Command Prompt.
  3. Try running devenv /Safemode in Command Prompt to see if you can apply it correctly.
  4. Try running devenv /Resetuserdata in Command Prompt to reset all of your VS environment and customization settings.
  1. 尝试在命令提示符中运行 devenv /Resetsettings 以消除设置损坏的原因。
  2. 尝试在命令提示符中运行 devenv /ResetSkipPkgs。
  3. 尝试在命令提示符中运行 devenv /Safemode 以查看是否可以正确应用它。
  4. 尝试在命令提示符中运行 devenv /Resetuserdata 以重置所有 VS 环境和自定义设置。

回答by Cheng Chen

If you have vs2012 installed in another disk(say disk D:) than the RC(installed on disk E:), try copying E:\Program Files\Micosoft Visual Studio 11to the corresponding folder on D:.

如果您将 vs2012 安装在另一个磁盘(例如磁盘 D:)而不是 RC(安装在磁盘 E:)上,请尝试复制E:\Program Files\Micosoft Visual Studio 11到 D: 上的相应文件夹。

回答by Escobar5

Well, I still don't know what was the problem, but solved it by uninstalling visual studio 2012 final, then installing visual studio 2012 RC, and then without uninstalling RC installed again the final version.

好吧,我仍然不知道是什么问题,但是通过卸载visual studio 2012 final,然后安装visual studio 2012 RC,然后不卸载RC再次安装最终版本解决了它。

Thanks everyone for your help.

感谢大家的帮助。

回答by Shrage Smilowitz

If you have any RC version it might be the cause.

如果您有任何 RC 版本,这可能是原因。

I had this issue with Visual Studio 2012 Developer Edition. I later found that i have Express Edition RC, i removed it and it solved the problem.

我在 Visual Studio 2012 Developer Edition 中遇到了这个问题。后来我发现我有 Express Edition RC,我将其删除并解决了问题。

And then i applied eggie's solution

然后我应用了eggie的解决方案

回答by Serj Sagan

Neither Oleg's solution (or variations suggested in the comments) or Repairing Visual studio worked for me. I finally stubmbled upon a fix shown here

Oleg 的解决方案(或评论中建议的变体)或 Repairing Visual Studio 都不适合我。我终于偶然发现了此处显示的修复程序

So 3 simple steps:

所以3个简单的步骤:

1) Close all instances of Visual Studio

1) 关闭所有 Visual Studio 实例

2) run Developer Command Prompt for VS2012(search in the Start Menu) as Administrator

2 Developer Command Prompt for VS2012以管理员身份运行(在开始菜单中搜索)

3) Then type devenv.exe /setup

3)然后输入 devenv.exe /setup

That did it for me.

那是为我做的。