How can I get user type C# syntax highlighting wor

2019-01-05 10:27发布

Somehow part of my syntax highlighting for C# code has disappeared in the VS 2012 IDE. Uninstalling, rebooting, and reinstalling does nothing, nor does resetting the colors in the options dialog.

Here are some examples of items which all appear in default (black) that normally have color which don't:

  • Attributes
  • System classes
  • My own classes

And here are some keywords that still have color:

  • using
  • public
  • void
  • var
  • for

Has anyone else experienced this and managed to fix it?

19条回答
地球回转人心会变
2楼-- · 2019-01-05 10:39

My problem was limited to having the "DateTime" type not showing up in light blue like other class names. I fixed it by simply switching back-and-forth between VS Themes. Discovered by accident. Much quicker than reset settings or repair install...

VS menu Tools -> Change Color Theme

查看更多
姐就是有狂的资本
3楼-- · 2019-01-05 10:39

I had the same issue....just uninstalling and re-installing alone did not correct the problem. After I un-installed, deleted all remnants of VS 2012 in program files, removed all related registry keys, and deleted the VS 2012 folder from My Documents, then re-installed, user types showed up in the display items in fonts and colors and everything went back to normal. My guess is that it was an issue with one or more of the registry keys but I can't be sure of that.

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-05 10:40

If none of the above work for you, delete all GUID-named folders under this registry key (make sure your Visual Studio instance is closed):

If you're using Visual Studio 2012: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\FontAndColors

If you're using Visual Studio 2013: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors

If you're using Visual Studio 2015: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\FontAndColors

Restart Visual Studio, and you should see a few various "User Types" to configure. You can then import your Fonts and Colors that you backed-up, and everything will be good to go. This may also work for previous and future versions of VS, but I have not tested.

Disclaimer: Make sure you export/backup your current Fonts and Colors settings before making these registry adjustments. I cannot be held responsible for you losing your configs :)

查看更多
Viruses.
5楼-- · 2019-01-05 10:41

Problem : Class name and Syntax showing in black color

Solutation:

Step 1: Remove Key :
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors

Step 2: Remove folder :
C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0

Step 3: Open command prompt (admin mode) and run below command line :
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv.exe /setup
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv.exe /ResetSettings

查看更多
贼婆χ
6楼-- · 2019-01-05 10:44

Here is a simple solution. Go to the directory where devenv is (for 2012 RC), and type devenv.exe /setup. It will fix your problem.

devenv.exe is usually in something like C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.

Edit: It has been suggested that you do this from the Visual Studio command prompt (Start>Microsoft Visual Studio>Tools>Visual Studio Command Prompt), and/or make sure your command prompt has administrator permissions.

Note for others: This has a very good chance of working for many other versions of Visual Studio, including 2008, 2010, 11 beta, ...

查看更多
叛逆
7楼-- · 2019-01-05 10:44

After trying several of the solutions listed here, I eventually found that my issue was caused by a very large (488000+ characters) string variable. Highlighting was working up to that line, but not after it. Once I reduced the length of the string, highlighting in the rest of the file resumed working normally.

查看更多
登录 后发表回答