Sandallic Posted December 10, 2004 Posted December 10, 2004 Hi, I have been working with a pretty big project for a while. I started to build this solution using regulare windows project. Today I got the orders to make this into a windows service. anyway, I have been trying to make this work for a several of hours, but I cant figure out the problem. I managed to install the service, but it doesnt seem to response at all. This is one part of my code Protected Overrides Sub OnStart(ByVal args() As String) '**************************************************** '* Making sure the logfile is there. '**************************************************** If Not File.Exists("updates.txt") Then Dim sr As StreamWriter = File.CreateText("updates.txt") sr.Close() End If LastMinute = Now() End Sub Not even this small part works. It doesnt create this file when I start my service, even thou it doesnt exists. Anyone knows anything about installing and building an windows service that I have missed? Need all help I can get. Thx, Sandallic Quote
VBAHole22 Posted December 10, 2004 Posted December 10, 2004 First off, this is the best place to start http://www.developerfusion.com/show/3441/ It shows you how to create an installer. Then you want to compile the code, run the dotnet command prompt install command, then start the service up. Secondly, add some error handling to your code so that you know if it is really even getting called. Thirdly, start out by writing to the application log so that you know your service is starting up. Lastly, Place your code in a sub and call it from the OnStart event. Just makes it cleaner. Quote Wanna-Be C# Superstar
VBAHole22 Posted December 10, 2004 Posted December 10, 2004 When you want to make changes to your code and test them you have a little bit of a process to go through. you have to: Stop the service Uninstall it using the /U flag at the comman prompt Change your code Recompile Re-Install Start the service again. Now I don't know if anyone else has an answer to this one but I have been having a heck of a time doing the above procedure unless I change the diaplayname and servicename in my service installer. I start out with MyService1 and then each subsequent change in code I bump it up one and recompile/install/start etc. If I don't do this it won't install at the command prompt because it says the old service by that name is marked for deletion. It's not a big deal but can be a hassle. Quote Wanna-Be C# Superstar
manmeet Posted August 28, 2005 Posted August 28, 2005 I am not sure why windows services behave like this, but to get rid of the error "service has been marked for deletion" - (1) recompile your service code (2)close the "services" window (under control panel) (3) install your .NET service. If the "services" window is not closed, you will def get the error. Well -things can be funny when it comes to WINDOWS :-) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.