Why are the “Paste JSON As Classes” and “Paste XML As Classes” commands disabled (grayed out) in Visual Studio? [closed]

老子叫甜甜 提交于 2020-04-11 10:44:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!