Link to home
Start Free TrialLog in
Avatar of Christian de Bellefeuille
Christian de BellefeuilleFlag for Canada

asked on

How to write a service with Visual Studio 2005 STD?

HI,

I've seen this article showing how to write a service (http://www.developerfusion.co.uk/show/3441/2/) with some snapshots, but the problem that i have is that i don't have all the options!

When i start a new project, i DON'T have the option WINDOWS SERVICE.  In this article, they don't mention anything about the fact that i wouldn't be able to write a service or not (http://msdn.microsoft.com/en-ca/vstudio/aa700921.aspx)...  

Anyone have this problem other than me?  Is this a limitation of the STANDARD version?

Thanks for the informations
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You will need to add a reference to the System.ServiceProcess.dll to your project.
Avatar of Christian de Bellefeuille

ASKER

I've just noticed that i can create an Empty Project.  Then i can add a "Windows Service" (just like if i add a form)...  and i get some stuff in it.  When i switch to code, i've exactly what you specified (i choosed VB.NET instead of C#).  

I also had the choice to add an installer to let it install the service, and choose how it should start (manual, auto, disabled).

So as far as i see, the pro version doesn't have much more informations available.

I'll investigate a little bit about this subject.  Thanks for your help

Imports System.ServiceProcess
 
Public Class Facilis_Media_SyncIt
 
    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
    End Sub
 
    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
    End Sub
 
End Class

Open in new window

Hi TheLearnedOne, i think that i've closed this case a bit too fast!

It doesn't work at all!  I don't know why, but for some reasons after installing the service, i go to the Services in the admin tools, then try to start my service.  0.25 second after i pressed the Start button, it tell me that it can't start in a "timely fashion".  

Usually we get this message when it hang on the "OnStart" for too long... but actually, 0.25 second is quite fast to get this message!

I've noticed that in the Project properties the application type was set to "Windows application".  So i've uninstalled the service, change that to Windows Service, then rebuild and reinstall.  But i got the same problem.

But when i get back again in the project properties after changing the app type to Service (and saved the project), it bring back the "Windows Application" again!

I don't think that i'm the only one to have this problem.  In this article explaining how to write services, look at comment #25 (http://www.devcity.net/Articles/190/4/article.aspx).

I'll call Microsoft to understand what's going on with their stuff...
I'm completely mixed up!  I just spoke with Microsoft, and they told me that i would need to upgrade.  They say that 2008 PRO should be able to let me develop Windows Services... but actually, i look at a microsoft page and they say that 2008 STANDARD should do the job (http://www.microsoft.com/products/info/product.aspx?view=22&pcid=6a94862a-9763-42db-a530-7b5c7353fbe7&crumb=catpage&catid=515c9859-958b-4433-b4f9-91f37258ca2f)

"Build software for Windows:
Develop with the Windows APIs or .NET Framework using the same tools to build Windows services, applications, utilities, games, or business applications."

I'll just give up... i'm not paying anything else.
Do you still need help?
no, thanks.   I've deleted the code i've done so you can't even try what i've written  But i'm sure that Microsoft did that on purpose and my code was correct.  The only way to write a service in the Standard Edition is to write it in C++.