Adil Chaudhry
Adil Chaudhry

Reputation: 299

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?

Upvotes: 17

Views: 45626

Answers (5)

user40594
user40594

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

codegasm
codegasm

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

Tim &#39;t Hart
Tim &#39;t Hart

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

qPCR4vir
qPCR4vir

Reputation: 3571

Creating the template by yours self:

  1. Create an empty C++ solution with both 2012RC (New Project -> Other Project Types -> Visual Studio Solutions -> Blank Solution) and MSVC2010 Express (New Project -> Visual C++ -> Empty Project).
  2. Using 2010 Express, create a new Windows Form App project (name it “myWForm11” or so) inside the folder of the 2012RC empty solution. Close 2010 Express saving all.
  3. Using 2012RC and the "add existing project", add the 2010 Express-WinForm App project into the empty 2012RC solution.
  4. Right click on the solution to upgrade VC++ projects to 2012RC "format"
  5. FILE -> Export Template ... -> Next> Type in Template name: "Windows Form App, C++ 2012RC" or so and some description too.
  6. Finish
  7. Close solution

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

Jesse Good
Jesse Good

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:

  1. Create an empty C++ solution with both 2012RC and MSVC2010 Express.
  2. Using 2010 Express, create a new WinForm App project inside the folder of the 2012RC empty solution. Close all saving.
  3. Using 2012RC and the "add existing project", add the 2010 Express-WinForm App project into the empty 2012RC solution.
  4. 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

Related Questions