Visual Studio 2017 - can't find Visual C++ Windows Forms

被刻印的时光 ゝ 提交于 2019-12-10 02:52:25

问题


So, I'm in awkward situation - I wanted to create Windows Form App using Visual Studio, but I can't find any place to create Visual C++ Windows Form template. I tried even to reinstall Visual C++, add other libraries and search answer online - no results.

I can of course create new Winforms in C#:

But not in C++:

Also, all possible modules in Visual Studio Update was checked:

I tried even add template from Online list:

What should I do next? I use Visual Studio 2017 Community Edition.


回答1:


Ok, I found a working way to creating Windows Forms in Visual Studio 2017.

  1. Create new CLR Empty Project:

  1. Add .cpp file for main function.

  2. In project add new item from UI->Windows Forms:

(If we didn't add main loop before the error will occur)

  1. Now we can add new elements to form from the Toolbox to the left (i spent measurable time looking for that).

  1. To run application we have to declare this instead of main function:

Also we need to tell Visual Studio that we are making Windows Application instead of Console Application:




回答2:


WinForms designer support for C++/CLI was dropped a long time ago in VS 2012. MS suggests using C# for your WinForms code, and only use C++/CLI if you need to interop with native code.

And if you do end up using C++/CLI for interop, keep that layer as small as possible. It's a second-class citizen in the .NET world and isn't even mentioned in Microsoft's recent post on their language strategy.



来源:https://stackoverflow.com/questions/44769210/visual-studio-2017-cant-find-visual-c-windows-forms

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