Question about dual (?) mode programs

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've started using Dot Net 2.0. What I am thinking about doing is writing
one of my apps to act either as a windows app or a console app, by clearing
the 'Enable Application Framework' checkbox and setting the Startup object to
'Sub Main' in a module file. Whether the app acts as windows or console will
be determined by command line arguments.

Is there any serious downside to doing this under 2.0? (In all likelyhood,
this will probably be a fairly lightweight app.)
 
Your variant is possible if you are ready to attach console yourself using
PInvoke and manage it in the code - see Console functions in Platform SDK
(Win32).

If you want to use standard .Net console window (Console class), I believe
you need to set your project as console app, otherwise console won't be
activated.

HTH
Alex
 
I am not sure I fully understand your response (I may need to read up on a
few items.) I forgot to mention that the only likely purpose of these apps
will be database operations. Can't think of any Win32 functions it might
have to access.

Thanks.
 
Is there any serious downside to doing this under 2.0? (In all likelyhood,
this will probably be a fairly lightweight app.)

A project is either Windows Forms or Console, can't be the both at same
times without coding something.
The best approach is the following :
- Follow the MVC design pattern : put all you useful code in a a few
business classes.
- Then create a Windows Forms app that will call these classes
- ...And create a new Console app that will also call the same library

You can put the three projects (business classes, WF app, Console app)
in the same solution so the 2 final project (WF and console) will
reference the class library.

Easy to do, no strange unsafe and buggy Win32 code to add, clean way to
program, easy to debug, etc..
 
Back
Top