Problems with starting windows service on windows xp SP3 - c#

I'm currently facing a problem which I can not resolve and I really don't know what to do anymore.
When I'm trying to start the service I receive the message: "The service is started but again also stopped, this because that some of the services will stop if they have nothing to do, for example the performance logs and the alerts service".
I've looked into the Windows Logs but nothing is written there which could describe why my service is all the time stopping. I've also tried to fire the windows service via the command prompt which gives me the message: "The service is not started, but the service didn't return any faults.".
I've tried to remove all keys which references to my service, which didn't resolve the issue.
I've searched on google (maybe not good enough) to find an answer but I didn't found any. I did found some websites which describes what I could do, but all of these suggestions didn't work.
This is kinda ** because I do not know where to look. I do not have any error message, i do not have any id which i can use to search on. I really don't know where to start and I hope you guys can help me on this one.
Detailed explanation about the windows service
OS: Windows XP SP3
.Net Framework: .Net 4.0 Client Profile
Language: C#
Development environment: Visual Studio 2010 Professional (but Visual Studio 2012 RC is installed)
Communications: WCF (Named Pipes), WCF (BasicHTTPBinding)
Named Pipes:
I have chosen for this solution because I wanted to communicate from a windows service to a windows form application. It worked now for quite some time but suddenly my windows service shuts it self down and I couldn't restart it anymore.
There are two named pipes services implemented: An event service which will send any notification to the windows form application and an management service which gives my windows form application the possibility to maintain my windows service.
BasicHTTPBinding:
The basic http binding makes the connection to a central server. This connection is then used for streaming information from the client to the server.
I do not know which additional information you will need, but if you guys need something then I'll try to give it as detailed as possible.
Thank you in advance.

Ok, I have solved the issue and really it is a stupid one. Windows XP will not throw any error or does not report to you that the book where all logs are stored is full!!! After cleaning the log my service started perfectly and keeps running. How stupid! :)

Related

Error IIS and Android

I'm Brazilian, and I apologize for my English, which is very bad
I've been facing a problem for some time, and I'm tired of looking for a solution in Portuguese.
I created a WCF service to be consumed by Android, hosted on a computer that I have at home with Windows server and iis installed, configured all the correct port releases for the application to work on the phone, but it has the following error in the execution: System.Reflection .TargetInvocationException
So I decided to host the WCF service on an external server, I used the number service. I just uploaded the files to it and changed the address references in the application to communicate with the WCF, and then it worked, so I guess some configuration that has to be done in IIS or in Windows itself, I'm waiting for some help. Thank you

C# Small Tray Application starting as windows Server

I have created a windows Form tray application in C# .NET 4.0 that does some random things, not important, for Windows XP SP3.
The intention is that the application is to be started using Windows Services and should be running as LocalSystem with "Allow service to interact with desktop" checked. I understand the security implications and that services are not meant to be running GUI's etc, but this is the point of the program and is being used for training purposes.
When I start the application using the Services.msc utility it starts fine, but after about 10 seconds it states "Error 1053: The service did not respond to the start or control request in a timely fashion"
I have looked at a number of other solutions without any luck, for example:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/dac443c1-f2fc-49c6-bdd4-5426edc946ee/how-to-start-calcexe-from-windows-service-
I don't really care about a nice programming example. I can either create a service then have the tray application called API's, but I don't know if the tray application will run with elevated privs, or create a forms application and hack it to run as a Windows XP service or get a proper service to launch an exe being my tray application...
Any examples would be much appreciated or links to coding examples etc.
For a windows service, if your overridden OnStart method performs a lot of work, you will get the "Error 1053: The service did not respond to the start or control request in a timely fashion" error.
You can call the ServiceBase.RequestAdditionalTime method with enough time required to perform whatever work is needed.
See http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicebase.requestadditionaltime%28v=vs.110%29.aspx for refrence.
Just in case this happens to someone else. I just used the Windows 2003 Resource kit and used 'SRVANY'.
More information is available here:
http://support.microsoft.com/kb/137890
and here:
http://www.tacktech.com/display.cfm?ttid=197
I just followed the instructions except for ticking the checkbox in Services "Allow Service to Interact with Desktop"
Thanks for the Answer Dietz, it is probably the correct way in getting it working but this is just a simple hack.

windows service working on windows 7 but not on windows server 2003

Solved the problem see the bottom of my post.
So I have a simple windows service that watches a specific folder and upploads files that come into it to a server using a web service.
It's working fine on my machine using windows 7 but when I try to start it on a windows server 2003, I receive an error: Error 1053: the service did not respond to start or control request in a timely fashion. But I get this message after only a few seconds.
I have created the ServicesPipeTimeout and set it to 60000 milliseconds.
I have tried running it from command line using sc query command and found out that the WIN32_EXIT_CODE is 0, which I think means that the service doesn´t even try to start because it find an error before it starts.
In the event viewer I get errors 7000 and 7009.
I am the Administrator on the windows server.
The only thing I haven´t tried is a hotfix I found from microsoft but I don´t want to use it because as I understand it, it is for when the service actually times out.http://support.microsoft.com/kb/886695
I have tried everything I can think of, is there anything that I am missing?
Gísli
EDIT: Re-installed the .NET framework and now I get a new error, Saying that the service controller can not be found.
EDIT: I setup the service with a setup project, not using the installutil command. This is because I need to get user input during the installation and save that in the registry.
EDIT: I have installed the .NET 4.0 framework, it wasn´t possible to install the service with out doing that.
In addition to what I wrote above I have also tried:
Rebooting.
Re-installing.
I have tried to change the permissions on the files that the service needs to access.
Changing permissions in the registry editor.
Edited the code so that the onStart function only starts one thread.
I think it is some kind of permission problem but I don´t have much experience dealing with Windows server.
Solution:
It turned out to be two seperate problems. The .NET framwork had to be repaired and I had to remove the try/catch clause that I had when starting the service. For some reason (unknown to me) the try catch block did something that made it impossible to start the service in a windows server 2003 but it ran fine on windows 7.
It would be very interesting to know why this is.
Thanks for all the help.
Gísli
Have you installed the right version of .NET Framework on the Server 2003 PC? What comes as standard on Windows 7 will need to be installed manually on an older OS.
You say "I have tried everything I can think of". Please edit the question to show what you have already tried so we don't suggest something you have already done.
EDIT:
Try also the Fusion Log viewer. Set it to log failures then start your service. Hit refresh then see if any errors are logged. Double-click a line for more details.
I'd guess that you installed the .NET 3.5 service using .NET 2.0? InstallUtil will work since the CLR is the same, but the service won't start because of .NET 3.5 dependencies.
See Also:
How to install a Windows service developed in .NET 3.5?
In your OnStart code you could wrap everything in a try-catch block and write the exception message and stack trace to a file using something like:
File.WriteAllText(#"C:\Temp\MyServiceLog.txt", exp.Message + exp.StackTrace);
This will help you analyze the problem. Also, I'm using a very simple way of debugging my services: I'm wrapping them in a WinForms wrapper if the session is interactive. For that, I need the following:
A form that creates an instance of the service class
New methods DoStart and DoStop in my service class, which are public and call the protected OnStart and OnStop methods
New code in above form's OnLoad and OnClose handlers, so the DoStart and DoStop methods of the service instance are called accordingly
Then I add the following code to the Main method in Program.cs:
if (Environment.UserInteractive)
{
Application.Run(new FormServiceHoster());
}
else
{
// ... old code to create service instance.
}
This way you're making the "service" run as an application when you just hit F5 in Visual Studio or double click the EXE in the Explorer. When the service is actually run as a service, the Forms-code is ignored.
Usually you can debug services by attaching to the process, however, that doesn't work for debugging the start and stop code. This method helps a great deal debugging the service start and stop code.
You will need to add references to System.Windows.Forms and System.Drawing manually.
This is the point where I bet you wish you had used some logging package like log4net, which might help tell how far your program gets.
Is it possible that the code in the OnStart event is actually taking longer than you expect. If so, you could move that code to a thread, so that the OnStart event finishes (and so Windows reckons the service has started) while your thread continues working.
Are you running the service as admin? If so, that usually rules out permissions issues. (If it still goes wrong, it will rule out the KB 886695 issue as that seems to only apply to local system).
Since you are using .NET 4.0 are you sure that either, the full version is installed, rather than the Client Profile, or that your application works with the client profile?

service installation on server 2003

I'm trying to install service which I created in visual studio 2008 on windows server 2003
the problem is that I'm keep getting the following error:
Error 1053: The service did not respond to the start or control request in a timely fashion
all the documentation I read about the issue suggested to install .NET Framework 1.1 Service Pack 1
my currently frame work is 3.5 so I guess it won't solve anything ,is there any solution to the issue ? if there is additional information I need to supply please guide me since I'm new to the server,services world.
If your service has any ongoing work to do, you should spawn a thread in OnStart and then return. If the service doesn't have ongoing work but may take a while to run, then you need to call RequestAdditionalTime.
The MSDN docs for managed Windows services are a bit lacking; this blog post fills in the details nicely.

wcf crashes in one pc and in the development pc runs perfectly

hi implementing an wcf service that executes scripts (C# code) saved in a specific folder.
but i have a problem it crashes in all pcs except the pc that im developing in all are the same edition of win7 . How ican see why it's crashing ?
the WCf service is hosted in a windows service
Check out the Event Viewer, both in the Application and System sections. That might give you some clues.
Also, security is a possibility since it only runs on the dev machine. But I'd start with the events.

Categories