Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do an application without form in C#? [duplicate]

Tags:

c#

windowless

Possible Duplicate:
Writing a Windows system tray application with .NET

Hi,
I am programming an application in .NET and I don't want to put it a windows interface.
I remember some time ago I did it with inheriting from the ApplicationContext class but now I can't achieve it.

How I could do it?

Thanks!

Edit: It's an application that is managed by a notify icon. It must appear the icon near the system clock but not a form. I'm doing this:

class Sync : ApplicationContext
{
    public Sync()
    {
        ...
    }
}

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Sync());
}
like image 500
Alfre2 Avatar asked Jun 18 '09 11:06

Alfre2


1 Answers

(obsolete now that you've edited the question to state systray; left for reference only)

If you want an exe without any UI (not even a console), but without it being a service etc - then write a windows forms app, but just don't show any forms! The fact that it is a winform app simply means you don't get a console window - but no UI is shown except that which you write. Look at the Main method (usually in Program.cs in the VS templates) to see what I mean.

like image 135
Marc Gravell Avatar answered Sep 21 '22 15:09

Marc Gravell