C# program without UI - c#

Is it possible to make a Visual C# program that runs without a console or windows form? If so, how?

Sure- set the build output type to Windows Application under Project Properties, and don't show a form in Main. You can do whatever you want in there- you just have to manage the lifetime of the app somehow (eg, how do you plan to shut it down?)

You can also create a Windows Service app; start and stop the app via the Services Management console.

Related

Start .Net Application After Logging in

I need to create an .Net application which is automatically start after windows logging in. on that time i dont want to show our desktop and windows related things.
Is it possible?I need to create one more layer between login and our Windows.That layer is our .Net Application
I don't quite get it. It is either a Windows Service, which is an application that runs in the background all the time, or some kind of a Kiosk application, which sits "on top" of everything and is effectively the only UI to the PC.
You can start make a Schedule Task and run it
http://windows.microsoft.com/en-au/windows/schedule-task#1TC=windows-7
p.s you can only can run cmd files

Converted console app to Windows Forms application. But need to run the program in both Forms and Console

I converted my console application to windows forms application. Now if I need to run this program in both forms and console what do i do? I tried running it as WinForms and console... in both the cases only one of them are opened. Any advice?
You have got two very different outputs which want to share the same code base for logic.
You will need to separate your application logic into a code library, then reference it from a Windows App and a Console App. In each app call the appropriate methods to perform whatever functionality you want.
You can start project in Console application and add windows forms in it. I tried in my projects. :)

Determine whether the class library is called from a windows based application

This is based on C#. I am having a classlibrary in which I would like to know specifically if its being called from a windows based application
I searched a lot but all I found was code to know if it was called from a Console application.
I only want to know if its called from a windows based application or not
Please Help
If you want to know whether the application is running as a service or system app and thus cannot display a dialogue, test the state of Environment.UserInteractive.
There is no easy way to determine if the application is a windows or cmd-based application. For example, I might build a winforms-based application that doesn't create a window and instead runs as command-line style application by not opening a window.
Two (not necessarily reliable) ways of testing if it's a windows-based app would be to test Application.OpenForms (if it contains forms, then it's a windows app) or Environment.GetCommandLineArgs() (if 0 args, assume it's a windows app).
If you absolutely need to know whether the app is a console or windows one, then you need to step out of the world of managed code and start delving into the exe file using unmanaged C++ code. There is just one byte difference between the two in the PE header of the exe file: Subsystem is set to 2 for a windows app and 3 for a cmd app. See http://msdn.microsoft.com/en-us/library/ms809762.aspx and http://support.microsoft.com/kb/90493/en-us for details if you really want to do this.

Create a process not an application in C#

I've created a simple application that I wish to be a process and not show up as an application inside taskmanager, simply because it is not an application. It was intended to be a process.
You might want to read about Windows Services.
Walkthrough: Creating a Windows Service Application in the Component Designer
Creating a C# Service Step-by-Step: Lesson I
You don't give much information about what you application does, but either Console or Forms will be displayed on the TaskManager, and even as a process it will be shown over the Processes tab so I'm not sure what are your intentions with this.

Creating VS 2010 executable for Daily Tasks

I want to create an executable in VS 2010. This executable will be create an excel spreadsheet and will transfer that file via FTP. I want this executable to be fired off via Windows tasks.
What is the best way to accomplish this? Would I create a regular windows form application, dll, or Empty Project, or windows service?
Thank you in advance for any assistance.
A plain old console application scheduled with the task scheduler should do the trick.
If you need the application to run when a computer is turned on but no one is logged in, create a service. If your application runs only when someone is logged in, but has no UI, use a console application. If your application runs only when someone is logged in and has a UI, use a Winforms app.
I'm not sure what the current best practice is, but in our shop we create console applications and use the task scheduler to execute them.
A library (dll) won't be executable from the task scheduler AFAIK, and a WinForms app isn't very useful for any app that runs automatically (i.e.: doesn't require user interaction).
A service would be appropriate for an application that needs to respond to system events/changes when they occur, which doesn't sound like your use case.

Categories