tags:

views:

125

answers:

5

How Do You create a .net application with no UI. How would I go about doing this? I don't want it to be a console application. The best choice would seem to be a winform application that never calls application.run.

The goal of the app is to be run and do a simple task. say check a server for an update or copy files. Nothing long running where a windows service would be necessary.

+3  A: 

It appears you answered your own question. Never call application.Run. In doing so you never instantiate a form, meaning the user never see's anything.

However if you're looking for an application to run in the background, you may be looking for a Windows Service application. Of which you can create one of these using the project template in Visual Studio

Neil N
+6  A: 

If Windows Service isn't an option, you can simply create an empty project (or console app) and set the compiler target to Windows Application in the project properties (/t:winexe command line option). This is essentially equivalent to your own proposal.

The whole point is, /t:winexe sets the subsystem flag in the generated binary to a Windows executable so that the command prompt is not shown when the app is executed.

Mehrdad Afshari
A: 

You are looking for a Windows Service. Windows services start when the system starts, and run in the background without any kind of UI. One caveat, they must be installed to start up, and debugging can be a little tricky. Visual Studio provides a Windows Service project template that can get you started.

jrista
A: 

Another fairly straightforward way of doing this is to create a winform application and Hide the form in its OnLoad method.

Bill Yang
Seems like Over Kill, why not just remove the form alltogether?
Neil N