PC Review Forums Newsgroups Microsoft DotNet Microsoft VB .NET Writing an app for both WinForms and Console use

Reply

Writing an app for both WinForms and Console use

 
Thread Tools Rate Thread
Old 04-04-2006, 11:25 AM   #1
Oenone
Guest
 
Posts: n/a
Default Writing an app for both WinForms and Console use


I'm writing an application that I'd like to be able to use both as a Windows
Forms application, and also as a Console application.

If the app is started with no parameters, it should display its window and
allow the user to interact with it. If parameters are provided, it should
instead run as a console application and should output various information
to the standard output channel (so that the output can be redirected if
required).

By setting my app as a Windows Application, all Console methods are ignored.
By setting my app as a Console Application, all attempts to display Windows
Forms are ignored.

Is there any way to get a single application to act in both of these
different ways?

Thanks,

--

(O)enone


  Reply With Quote
Old 04-04-2006, 12:30 PM   #2
jan.hancic@gmail.com
Guest
 
Posts: n/a
Default Re: Writing an app for both WinForms and Console use

You can show windows form even dough your proejct is console type. You
just have to refrence the Windows.Forms.dll.

I would suggsest you that you put your logic and everything that does
not need a interface in a DLL and then make 3 seperate applications.
One for starting either a console or windows version. And then one
consoel and one windows version.

  Reply With Quote
Old 04-04-2006, 01:27 PM   #3
Oenone
Guest
 
Posts: n/a
Default Re: Writing an app for both WinForms and Console use

jan.hancic@gmail.com wrote:
> You can show windows form even dough your proejct is console type. You
> just have to refrence the Windows.Forms.dll.


You're right -- and I described the behaviour incorrectly in my original
post. This way it works fine except that when running from within Windows,
an empty console window appears in the background, which looks awful.

> I would suggsest you that you put your logic and everything that does
> not need a interface in a DLL and then make 3 seperate applications.
> One for starting either a console or windows version. And then one
> consoel and one windows version.


Thanks for the suggestion!

--

(O)enone



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off