Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Program with both WinForm and Console Interfaces

I have a simple question and I'm sure it's been answered, but I can't seem to find the solution I'm looking for.

My basic question is that I've created a console app in .Net that runs automatically on a task scheduler every day, but now my clients also want a windows form-based interface that they can use to run special runs (they use the GUI to specify a few parameters - such as specific dates, etc - to make the program run a bit differently).

The way I thought to do this would be to convert my console app to a WinForm solution and to include Command Line Arguments for when I wanted it to run as the original console app with defaults, but I'm thinking that's not the right way since it would still involve a form load.

My other thought was to convert the "engine" part to a DLL and to make 2 executables - One a console app and one a winforms app, but I'm not sure if that's right either / could lead to more maintenance.

What is the correct way to do this?

I'm writing this in VB, but am equally comfortable with C# solutions if that is easier for you.

Thanks!!

like image 691
John Bustos Avatar asked Aug 06 '14 19:08

John Bustos


1 Answers

Typically, I'd split the logic into a library, then make a simple console app and a simple Forms app to call into the logic in the library.

You can then distribute these separately and use them as they are intended, without duplication of code.

like image 105
Reed Copsey Avatar answered Oct 29 '22 23:10

Reed Copsey