windows-services

Windows Service System.Timers.Timer not firing

為{幸葍}努か 提交于 2019-11-26 22:48:31
问题 I have a Windows service written in C# which is meant to perform a task every few minutes. I'm using a System.Timers.Timer for this but it doesn't ever appear to fire. I've looked at many different posts here on SO and elsewhere and I'm not seeing what is wrong with my code. Here is my code, with non-timer related items removed for clarity... namespace NovaNotificationService { public partial class NovaNotificationService : ServiceBase { private System.Timers.Timer IntervalTimer; public

Xps printing from windows service

删除回忆录丶 提交于 2019-11-26 22:48:00
问题 I'm trying to print XPS documents from a windows service on the .net framework. Since Microsoft does not support printing by using System.Drawing.Printing nor by using System.Printing (WPF), I'm using the native XPSPrint API. This is suggested to me by Aspose in http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-print-a-document-on-a-server-via-the-xpsprint-api.html. When I try to print an XPS document from a windows service, the result contains strange characters

How can a Windows Service determine its ServiceName?

匆匆过客 提交于 2019-11-26 22:43:40
I've looked and couldn't find what should be a simple question: How can a Windows Service determine the ServiceName for which it was started? I know the installation can hack at the registry and add a command line argument, but logically that seems like it should be unnecessary, hence this question. I'm hoping to run multiple copies of a single binary more cleanly than the registry hack. Edit : This is written in C#. My apps Main() entry point does different things, depending on command line arguments: Install or Uninstall the service. The command line can provide a non-default ServiceName and

Why does print screen in a Windows Service return a black image?

一世执手 提交于 2019-11-26 22:26:20
问题 protected override void OnStart(string[] args) { base.OnStart(args); CaptureScreen(); } protected override void OnStop() { base.OnStop(); } private void CaptureScreen() { Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); Graphics graphics = Graphics.FromImage(printscreen as Image); graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size); printscreen.Save(@"L:\" + Counter++ + ".jpg", ImageFormat.Jpeg); } I checked interact with desktop tried

Can I have multiple services hosted in a single windows executable

房东的猫 提交于 2019-11-26 22:16:49
问题 My question is essentially the same as the following one but the answer did not help me. .NET Windows Service - multiple services in one project Essentially, I have 3 services, lets say "Service1", "Service" and "Service3". ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Service1("Service1"), new Service2("Service2"), new Service3("Service3") }; ServiceBase.Run(ServicesToRun); I also have installer classes with corresponding serviceInstaller.ServiceName = "ServiceX" for

How can I run a Windows GUI application on as a service?

不羁岁月 提交于 2019-11-26 22:13:36
I have an existing GUI application that should have been implemented as a service. Basically, I need to be able to remotely log onto and off of the Windows 2003 server and still keep this program running. Is this even possible? EDIT: Further refinement here... I do not have the source, it's not my application. Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application. If you have the source code, converting the non-GUI code into a service is easy - Visual Studio has a

How do I debug Windows services in Visual Studio?

戏子无情 提交于 2019-11-26 21:38:22
Is it possible to debug the Windows services in Visual Studio? I used code like System.Diagnostics.Debugger.Break(); but it is giving some code error like: I got two event error: eventID 4096 VsJITDebugger and "The service did not respond to the start or control request in a timely fashion." Chirag Use the following code in service OnStart method: System.Diagnostics.Debugger.Launch(); Choose the Visual Studio option from the pop up message. Note: To use it in only Debug mode, a #if DEBUG compiler directive can be used, as follows. This will prevent accidental or debugging in release mode on a

How to call method from running windows service

走远了吗. 提交于 2019-11-26 21:37:55
问题 I have created and started windows service Service1 (with exe as MyService.exe) using c# 2005. . I have included a method GetMyRandomNumber() that returns a random double value. The problem here is how could use this running service and how could i call the method. I have tried adding reference of MyService.exe and access the method as - Service1 s = new Service1(); MessageBox.Show(s.GetMyRandomNumber().ToString()); But found that the method is not called from the running instance of the

Error 1053 the service did not respond to the start or control request

╄→гoц情女王★ 提交于 2019-11-26 21:27:44
问题 I've written a Windows Service in C# that basically checks my db every minute for orders, generates a PDF from these orders, and emails it. The logic works perfectly in my tests etc.. When i create the service, and install it using the setup project, when I go to start the service in the services mmc, I get: error 1053 the service did not respond to the start or control request in a timely fashion My OnStart method looks like this: protected override void OnStart(string[] args) { /

What are the specific differences between .msi and setup.exe file?

那年仲夏 提交于 2019-11-26 21:25:11
I searched a lot, but all are guessed answers. Help me to find the exact answer. Kevin Kibler An MSI is a Windows Installer database. Windows Installer (a service installed with Windows) uses this to install software on your system (i.e. copy files, set registry values, etc...). A setup.exe may either be a bootstrapper or a non-msi installer. A non-msi installer will extract the installation resources from itself and manage their installation directly. A bootstrapper will contain an MSI instead of individual files. In this case, the setup.exe will call Windows Installer to install the MSI.