问题
I'm using Visual Studio 2017 15.9.0 Preview 4.0. I'm trying to use the "Paste XML As Classes" command available under "Edit > Paste Special" but it's grayed out:
I got the (incorrect) feeling that this command would allow me to pick a file that contained XML, or have some other sort of UI. The articles I None of the articles I found talk about cases where these commands are disabled, and all indications lead me to believe it should be available in this version of VS:
https://dailydotnettips.com/did-you-know-you-can-automatically-create-classes-from-json-or-xml-in-visual-studio/
https://improveandrepeat.com/2017/08/paste-xml-as-class-in-visual-studio-2017/
https://www.c-sharpcorner.com/article/how-to-paste-json-as-classes-or-xml-as-classes-in-visual-stu/
I did find one article (below) that discusses when it's missing (which is obviously not the case here) because the project must target Framework 4.5 or above, but that's the exact .NET version I'm targeting.
https://blog.codecalculated.com/2015/01/02/paste-xml-as-classes-missing-in-visual-studio/
回答1:
I finally came across this lone article that gave me the solution:
http://www.selcuksasoglu.com/2014/06/18/creating-classes-with-xml-files-using-net-4-5/
In it, it says
If you fail to copy the xml file to your clipboard, you may notice that “Paste XML as Classes” is disabled.
Wow, that was easy. Wouldn't it have been great if Microsoft thought to include a little tool tip with those grayed out commands?
来源:https://stackoverflow.com/questions/53119308/why-are-the-paste-json-as-classes-and-paste-xml-as-classes-commands-disabled