A little while back I had to create a Windows Service for a client that was meant to live on a Windows 2008 Server. Having Visual Studio 2012 at my disposal, I decided to create the service in C# using .NET 4.5.
My client decided to install the application on his machine but was getting errors that it was not a recognized 32-bit application. This made no sense to me since I was having it installed as a 64-bit application. However, not knowing that the application was being installed onto a machine with Windows Server 2003, I dutifully recompiled the application as 32-bit, but the customer was receiving the same error.
This is when I found out what the current server’s operating system was, so I once again set the application to compile normally (by not specifying whether it was 32- or 64-bit) but had Visual Studio use the .NET 4.0 framework instead.
My customer received a new error. The service did install but would not run; instead it would immediately give the error “the service did not respond in a timely fashion.”
There are a few postings regarding this issue. Microsoft has one on steps to reduce the behavior at http://support.microsoft.com/kb/839174; other sites have one change registry settings.
Mine was a much simpler issue. I had Visual Studio change my application from .NET 4.5 to .NET 4.0, but for whatever I did wrong, the configuration file did not update. That’s my fault; but the offending line was my supported runtime version:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
Changing this to 4.0 solved the problem.