My problem is that I want to create a background application but with a user interface that could be restored and minimized to the system tray and it starts with windows. I trie
Here's a way to create an app that isn't tied to a Form. Use a Standard WinForms Project, but pass your custom implementation of ApplicationContext to Application.Run()
:
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MyContext());
}
}
public class MyContext : ApplicationContext
{
public MyContext()
{
// this is the new "entry point" for your application
// use Application.Exit() to shut down the application
// you can still create and display a NotifyIcon control via code for display in the tray
// (the icon for the NotifyIcon can be an embedded resource)
// you can also display forms as usual when necessary
}
}