windows-services

WCF hosting in Windows Service?

Sometimes I see people hosting a WCF Service using Windows service and sometimes WCF Service hosted using IIS? What is the big difference? In which scenarios we need to go with method 1) and in which scenarios we need to use method 2) ...

c# - log4net not working in a windows service

I have a console app which i am converting into a windows service. As a console app my log4net logging is working fine. But converting it into a windows service, my log4net logging has stopped working. I have added this to my assemblyInfo.cs in the service project [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config",...

How do I retrieve the username that a Windows service is running under?

Given a service name, I would like to retrieve the username that it runs under (i.e. the username shown in the 'Log On' tab of a service's properties window). There doesn't appear to be anything in the ServiceController class to retrieve this basic information. Nothing else in System.ServiceProcess looks like it exposes this information ...

How do I build and deploy a Windows Service with TFS 2008?

I have a build server with many builds for web sites and web services. I'm doing some new code using WCF; my new code runs as a Windows Service. Ordinarily, when I make changes to a web site, I "check out" the files I need to edit from TFS, make the changes, "check in" the files, and then perform a build. At this point, my new code is...

Visual Studio - Debug vs Release

I built a windows service, targeted for .NET 2.0 in VS 2008. I run it as a console app to debug it. Console app is working great. I put it on my local computer as a service, compiled in debug mode, still working great. I'm ready to release now, and suddenly, when I set it to release mode, the service compiles and installs, but nothing ...

Use PowerShell to stop-process, can i bypass confirm?

Hi All, I'm a powershell newbie, but I often find myself starting and stopping a small group of services when I'm debugging some code. In Powershell I can easily stop the processes using a wildcard but it makes me confirm. There is a -confirm parameter, but I must not be using it correctly? `Stop-Process -ProcessName alcore.* -Confirm` ...

How to test the reactivity of a Windows Service?

Hi, I'm programming a monitoring application that needs to display the state of several windows services. In the current version, I can know whether a service is Running, Stopped, Suspended or in one of the pending states. That's good, but I'm wondering if there is a way to test if a service is actually responding? I guess it can be in ...

System.Diagnostics.Debugger.Launch(); on Visual Studio C# 2010 Express edition

Hi, I have a windows service where I use System.Diagnostics.Debugger.Launch(); to debug the service. It worked on VS 2010 Pro RC, not on the express edition... Is there a way to debug a windows service with express edition ? Thanks in advance ...

Intense Distributed C# (WCF) Architecture Design.

I want to design a new distributed application, but I have a few queries that I need some genius advice on, hopefully from you people: Scenario I currently support a legacy application that is starting to fall between the cracks. It is a distributed Client-Server app implemented using .Net Remoting. I can't explain exactly what it does...

Windows Service Setup Project Problems Converting From VS.NET 2008 to 2010

I'm trying to convert a solution from VS.NET 2008 to 2010. The solution includes a Windows Service project and a Setup project that installs the Windows Service. I'm having trouble compiling the Setup project. I've tried starting this over from scratch a few times, following the tutorial here under the section titled To create a setup pr...

Installing different instances of the same Windows service with a Setup project

I have a Windows service with an Installer. In the constructor of the Installer, I am setting the ServiceName and DisplayName dynamically using the version number of another assembly that the service references. I also set the ServiceName property of the ServiceBase to the same value in its constructor. When I use Installutil from the...

Exception handling best practice in a windows service?

I am currently writing a windows service that runs entirely in the background and does something every day. My idea is that the service should be very stable so if something goes wrong it should not stop but try it next day again and of course log the exception. Can you suggest me any best practice how to make truly stable windows servic...

Accessing SQL Server over a network from a Windows Service

I have created a class that will connect to SQL Server to run a stored procedure. When this class is used in a Windows Forms solution, the database can be accessed successfully. When the class is put into a Windows Service, I get the following error: A network-related or instance-specific error occurred while establishing a co...

Installing a .NET Windows Service on a machine that doesn't have Visual Studio installed

Hi all I have created a Windows Service (called MuskOx) which runs on my development machine (which obviously has Visual Studio installed). The Bin folder of the project contains the following files: InstallUtil.InstallLog muskox.InstallLog muskox.InstallState MuskOx.exe.config MuskOx.vshost.exe MuskOx.vshost.exe.config MuskOx.vshost...

C# FrameWork 4 64 Bit Service InstalUtil Problem

Platform WinServer 2008 R2 32 Bit Version of Service. 32 bit Instalutil works OK Took service and components upto Framework 4 and 64 bit. 64 bit InstalUtil complains Could not load file 'Path' An attempt was made to load a program with an incorrect format .. Any thoughts? ...

C++ programming for HTTPS

Hi, I am a C++ programmer new to HTTPS. I need to write a COM based windows service in C++ which can handle HTTPS requests. But for that I would need to understand how the technologies and protocol fit together. I understand this is a very open ended question but my intent is to find some documentation that introduces a C++ programmer ...

Windows Service running as LocalSystem but needs to start a process as the currently logged on user

I'm running a windows service (written using .NET) as the user - LocalSystem. From the service, I need to start a process but as the currently logged on user. If I user Process.Start(process_name), it runs with the privilege of the service by default - that's as LocalSystem. How do I impersonate the currently logged on user and run the ...

Timed windows service crashing due to multiple threads running

Hi, I'm working on a simple web service which exports data from some data store into the database. The service runs every 20 seconds (testing interval). Intervals are implemented through System.Timers.Timer class. What is happening at the moment is: Service starts Timer starts 20 seconds pass and service starts the export Export do...

Double click to start Windows Service

Hello, How do I make my Windows Service to work in the following way... 1.) Automatically start after it installs 2.) Automatically start even if we simply double click on the executable In other words,I dont want to use the "NET START","SC" commands and dont want to start it through the services console. I just want my Service to au...

Windows Service Error Event

In ASP.Net I can use a http handler or module to catch errors. I need something equivalent for my windows service. I'm thinking something like Application.OnError += ErrorHandlingMethod; Any ideas? ...