windows-services

Is it possible to create a standalone, C# web service deployed as an EXE or Windows service?

喜欢而已 提交于 2019-11-29 05:33:52
Is it possible to create a C# EXE or Windows Service that can process Web Service requests? Obviously, some sort of embedded, probably limited, web server would have to be part of the EXE/service. The EXE/service would not have to rely on IIS being installed. Preferably, the embedded web service could handle HTTPS/SSL type connections. The scenario is this: customer wants to install a small agent (a windows service) on their corporate machines. The agent would have two primary tasks: 1) monitor the system over time and gather certain pieces of data and 2) respond to web service requests (SOAP

Code for executing method every day at specific time C# (Windows Service) failed

吃可爱长大的小学妹 提交于 2019-11-29 04:36:52
I had this code to execute method of windows service every day at 5am: EDIT: MyService ws = new MyService (); protected override void OnStart(string[] args) { if (serviceHost != null) { serviceHost.Close(); } serviceHost = new ServiceHost(typeof(MyService)); serviceHost.Open(); double TimeOfExecution = 5; DateTime now = DateTime.Now; DateTime today5am = now.Date.AddHours(TimeOfExecution); DateTime next5am = now <= today5am ? today5am : today5am.AddDays(1); System.Threading.TimerCallback callback = new System.Threading.TimerCallback(ws.MethodToExecute()); var timer1 = new System.Threading.Timer

How can I show a Notification Area Balloon and Icon from a Windows Service?

喜夏-厌秋 提交于 2019-11-29 04:33:46
I have a Windows Service that is always running when the user starts their workstation. This Windows Service is critical and I would like to show a Balloon Notification in the Notification Area when certain things happen such as the Service Stops, Starts, Restarts etc. For example: Also, is there a way to show a Notification Area Icon for my Windows Service? Matt Davis The days of Windows services interacting directly with the desktop are over, so you have to find another way. What I have done is create a normal WinForms application that includes a NotifyIcon. The behavior of this application

windows service - config file

岁酱吖の 提交于 2019-11-29 04:25:33
I know this has probably been asked before but I can't seem to find the right answer for me. I have a windows service named foobar.exe . I have an application configuration file named foobar.exe.config in the same folder. Is the config file only read at startup? I would like to make changes to the config file without having to restart the service but that is the only way I can get the new settings read. What am I doing wrong? Can a windows service have a dynamic config file? .NET applications will read their config files at startup and cache them for performance reasons. I see two basic ways

what is invalidate,update methods do in VC++

时间秒杀一切 提交于 2019-11-29 03:48:31
问题 i have small doubt regarding the window functions in c++. what exactly "invalidate()" function do? what message does it sends?when we need to call this? also what is "update()" function? is "invalidaterect()" works similar to "invalidate()" function?. Thanks 回答1: CWnd::Invalidate() invalidates the entire client area of a window, which indicates that the area is out of date, and should be repainted. You would typically call this on a control that needs to be redrawn. CWnd::InvalidateRect()

Service already exists (when it clearly doesn't)

瘦欲@ 提交于 2019-11-29 03:29:14
I'm trying to create an installer for a Windows Service I developed. This installer has a custom UI at one point and it's the first time I do something like that so I installed and uninstalled the service a few times to make sure everything was like I wanted to in the installer. Now my issue is that when I try to install the service, it fails with Error 1001: Specified service already exists, but the service is listed nowhere in the registry, the services.msc console, or by sc query . Can anyone give me a clue of what's happening and how to fix it? Thank you Edit: Thanks for your replies. I re

Installing a Windows Service with dependencies

一个人想着一个人 提交于 2019-11-29 03:28:47
My installer program doesn't suppport installing services but I can run a program/command line etc so my question is how can I install a Windows Service and add 2 dependencies using the command line? The program is a .Net 2.0 app. Thanks You can write a self-installing service and have it set a list of services your service depends on when the installer is executed. Basic steps: Add a reference to System.Configuration.Install to your project. Add a class that derives from System.Configuration.Install.Installer and has the RunInstaller attribute applied. In its constructor create both a

Windows Service or Scheduled Task, which one do we prefer?

独自空忆成欢 提交于 2019-11-29 03:07:35
If we need to write a program that works periodically, which way do we prefer? Writing a windows service or writing a console application which works as scheduled task? I would suggest running the process as a scheduled task if you can, and writing a service only if you need to. Services are quite a bit more difficult to write (correctly), and if you're running your process on a schedule of any sort, you're much better off using the windows scheduler than attempting to build a scheduler of your own (within the servce). The windows task scheduler is more efficient than your home-made scheduler

How to pass parameters to Windows Service?

走远了吗. 提交于 2019-11-29 03:05:05
I tried to pass parameters to a windows service. Here is my code snippet: class Program : ServiceBase { public String UserName { get; set; } public String Password { get; set; } static void Main(string[] args) { ServiceBase.Run(new Program()); } public Program() { this.ServiceName = "Create Users Service"; } protected override void OnStart(string[] args) { base.OnStart(args); String User = UserName; String Pass = Password; try { DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"); DirectoryEntry NewUser = AD.Children.Add(User, "user"); NewUser.Invoke(

UnhandledException handler in a .Net Windows Service

混江龙づ霸主 提交于 2019-11-29 02:56:48
Is it possible to use an UnhandledException Handler in a Windows Service? Normally I would use a custom built Exception Handling Component that does logging, phone home, etc. This component adds a handler to System.AppDomain.CurrentDomain.UnhandledException but as far as I can tell this doesn’t achieve anything win a Windows Service so I end up with this pattern in my 2 (or 4) Service entry points: Protected Overrides Sub OnStart(ByVal args() As String) ' Add code here to start your service. This method should set things ' in motion so your service can do its work. Try MyServiceComponent.Start