Reputation: 299
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?
Upvotes: 17
Views: 45626
Reputation: 11
I just created a new project in VS2010. Then import it into VS2013.
You will find the form designer doesn't always work with this. Change the source file slightly and save it. The form designer will then wok ok until you load in the project again.
Upvotes: 0
Reputation: 726
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 ;)
Upvotes: 14
Reputation: 391
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.
Upvotes: 39
Reputation: 3571
Creating the template by yours self:
Now you can create WF App in 2012RC “as always” (New Project -> Installed -> Templates -> Visual C++ -> Windows Form App, C++ 2012RC).
It works and it is simple! But I don’t know all the consequences.
Upvotes: 1
Reputation: 52365
Yes, microsoft has removed the option, here is the response from microsoft (reference):
C++/CLI is a great solution for interop, but we do not recommend creating brand new UI applications using C++/CLI.
The workaround provided by the link is:
- Create an empty C++ solution with both 2012RC and MSVC2010 Express.
- Using 2010 Express, create a new WinForm App project inside the folder of the 2012RC empty solution. Close all saving.
- Using 2012RC and the "add existing project", add the 2010 Express-WinForm App project into the empty 2012RC solution.
- Right click on the project to convert it to 2012RC "format"
It works and it is simple! But I don’t know all the consequences.
Upvotes: 7