Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows form CLR application in Visual studio 2012 RC?

quick question, im just trying out VS2012 and trying to make a c++.net app but for the life of me i cant find the option anymore when making a new project.

In vs2008 it used to be under new project>visual c++> CLR>windwos form application.

Have they removed the option to make c++/CLR application in .net from vs2012? Or is it something i must download?

like image 951
Adil Chaudhry Avatar asked Jun 21 '12 02:06

Adil Chaudhry


People also ask

How do I create a CLR project in Visual Studio?

To create a C++/CLI project in Visual StudioIn Solution Explorer, right-click on the top to open the Create a New Project dialog box. At the top of the dialog, type CLR in the search box and then choose CLR Empty Project from the results list. Choose the Create button to create the project.

What is Visual Studio CLR?

Available starting in Visual Studio 2019 version 16.4, /clr:netcore creates metadata and code for the component using the latest cross-platform . NET framework, also known as . NET Core. The metadata can be consumed by other . NET Core applications.

Which window is used to design a form in VB?

vb [Design] window, double-click the Click this button to open the Form1. vb window. Another option is to expand Form1. vb in Solution Explorer, and then select Form1.


2 Answers

Although Microsoft removed the option to create a C++/CLI Windows Forms application, the template files are still installed. The only thing missing seems to be the .vsz files and a registration in the vcNET.vcdir file. I have recreated these files and put them up for download here.

Install the files and you should be able to create WinForm apps in C++/CLI again.

like image 96
Tim 't Hart Avatar answered Oct 17 '22 01:10

Tim 't Hart


Well, many people have faced this problem. Here is what I follow:

Create a Visual C++ --> CLR --> CLR Empty Project (Obviously you specify the Name and the Directory).

Once it gets created, right-click on the project and select "Add --> New Item".

Under the UI tab, select "Windows Form". Name your form and click OK. This form would get added to the project.

After the form gets added, copy the following code inside the YourFormName.cpp:

using namespace System;
using namespace System::Windows::Forms;

[STAThread]
void Main(array<String^>^ args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    Project1::MyForm myForm;        //NameOfProject::NameOfForm instanceOfForm;
    Application::Run(%myForm);
}

We're almost done...

Now under the Project Properties, expand the Linker section and select "System". Under the subsystem option, choose Windows(/SUBSYSTEM/WINDOWS)

Now add an entry point. Under the "Linker-->Advanced", choose "Main" as the "Entry Point"

Build and Run..Voila!!

P.S.: This is only an empty form ;)

like image 41
codegasm Avatar answered Oct 17 '22 00:10

codegasm