Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Winform App to Console app

Is there a quick and dirty way (or a VS Macro) to convert a WinForms app to a Console App? I have a number of these apps that are no longer needed as Winforms apps. I suppose I could create a bunch of new projects and copy paste modules and classes over, but if it's just a matter of removing the single form that I have and editing/deleting a few things, I'd rather do that.

like image 592
Todd Main Avatar asked Aug 06 '10 19:08

Todd Main


2 Answers

You can change the project settings to create a Console Application instead of a Windows Application (just hit Ctrl+Enter on the project in the Solution Window, and make that change).

That will compile the application as a Console Application, and you'll get a console. However, you'll still get your forms. If you want to not have Windows Forms, you'll need to remove the forms, and replace their functionality with command line arguments or configuration. You can then remove the Windows Forms references, and it'll be converted.

like image 169
Reed Copsey Avatar answered Oct 18 '22 17:10

Reed Copsey


No, there is not. It's extremely dependent upon how the program was originally written. If the original programmer made the system fairly modular, this shouldn't take you too long. If all of the logic is in the WinForms code-behind, you have some serious work to do.

It's manual programming/refactoring work.

like image 6
Dave Markle Avatar answered Oct 18 '22 17:10

Dave Markle