Target schema for validation - missing in VS 2012

2019-09-04 16:29发布

问题:

In a MVC4, razor view, I am unable to get HTML5 intellisense.

After adding AngularJS references to VS2012 for intellisense, I still wasn't getting the any of the AngularJS directives to appear.

I have the HTML5 schema enabled (Tools/Options/Text Editor/HTML).

I also don't see any of the HTML5 intellisense as shown here.

When I type the

<

Intellisense is "text".

Other tags show a green line with the message "Validation ($SCHEMA$): Element 'script' is not supported.

Looks like there's a disconnect somewhere with my schemas.

I also tried added the target schema for validation to the toolbar and received the error:

---------------------------
Microsoft Visual Studio
---------------------------
Could not complete the action.
---------------------------
OK   
---------------------------

How can I resolve this?

回答1:

I have had exactly the same problem with VS 2013. I had been messing about with the schemas used for validation, so I reckoned that was the problem, turns out I had likely corrupted one of the files.

Find a "healthy" install of VS 2012 (maybe install on another machine?), zip & copy the following directory:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\schemas\html

Delete the directory from the "unhealthy" VS and copy the "healthy" one into it's place. Then re-start VS.

For 2013, you may also need to do the same for the following directory:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\Web\Schemas\1033\HTML

Prior to this I had also done a "Devenv.exe /Setup" and "Devenv.exe /ResetSettings", but I don't think these are necessary.