none
New VS Windows Service has no startup object RRS feed

  • Question

  • Hi 

    I have everything in position for my Service. I have not created one before but I followed the guides and I am at the installer part. Then i noticed in my Project Properties | Application that there is no Startup object set.

    From googling this problem, it seems unclear what Output type should be for a service (clearly it can't be class library as that's just a dll) and it isn't console type so that leaves Windows Application (which also sounds wrong as it's a service with no forms..).

    I know that it is OnStart instead of Start in the service itself. 

    I come from a heavily technical background, usually Java/Eclipse etc so feel free to be as technical as you like in your reply.

    below is a shot of my setup, everything seems to be in place.

    Friday, May 31, 2019 1:47 PM

Answers

All replies

  • See the Program class in my sample service

    https://github.com/karenpayneoregon/WindowsInstaller/blob/master/KarenPayneService/Program.cs#L16


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, May 31, 2019 2:34 PM
    Moderator
  • Hi actually I found another tutorial that gave a Program.cs example and this step was missing from the other two tutorials.

    I'll check your link too. (Edit: checked yours and see my new addition is the same)

    I've done the following and i am now battling installer error:

    And I am now battling this:


    Friday, May 31, 2019 2:47 PM
  • The repository I mentioned is for an installer which can also assist with debugging.

    https://github.com/karenpayneoregon/WindowsInstaller

    See also https://social.technet.microsoft.com/wiki/contents/articles/52152.windows-service-developer-gui-for-install-while-in-development-mode.aspx


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, May 31, 2019 2:59 PM
    Moderator
  • OK thanks will check.

    It looks like with my current one, the error originally was this line:

    So commenting it out then prompted a dialog instead so I entered login details. It didn't work as me, as expected (despite running cmd as admin)

    So I reran cmd as a service account, but i think this svc doesnt have rights on my work PC here:

    So I will check with Desktop support and/or Infra to see.

    I will also check your useful looking sln too

    Friday, May 31, 2019 4:15 PM
  • Hey the final part was just getting desktop support, at the client site I'm working at, to assist with the installation.

    The next part is working out why some things are not working as expected (I suspect account it's running as).

    So when it installs it prompts for a login, so I used my own, but is there something special I need to do with regard to the account it is using? I've not used Windows Services before so I suspect it's locked down unless told otherwise?

     

    Monday, June 3, 2019 3:39 PM
  • Also, now ive made changes how do I uninstall it first? As I assumed that if I ran the install again it would overwrite but it doesn't.. :)
    Monday, June 3, 2019 4:50 PM
  • Also, now ive made changes how do I uninstall it first? As I assumed that if I ran the install again it would overwrite but it doesn't.. :)

    See the following

    https://github.com/karenpayneoregon/WindowsInstaller/blob/master/ServiceInstaller/Classes/WindowServiceInstaller.cs#L65


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, June 3, 2019 6:40 PM
    Moderator
  • Hi OK thanks

    I will check it thanks. Where does this code plugin relative to what I already have please?

    Do I inject it here?

    Tuesday, June 4, 2019 9:05 AM
  • This code is inside InitializeComponent from autogenerated projectInstaller

    

    Tuesday, June 4, 2019 9:11 AM
  • Where does it go? Well there has to be a logical condition to trigger the uninstall which I can't tell you that.

    My util was never meant to run in a service but if you want to find a place in a condition to call the uninstall as per this code. Add this class and this class to your service project.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, June 4, 2019 10:20 AM
    Moderator
  • Ok rgeat thanks for that.

    I did find the /u flag for use earlier this morning as I'm under pressure (trading floor, doing support of stuff too and trying to write this in quiet time :))

    Tuesday, June 4, 2019 10:48 AM
  • Yes, that is in the code here.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, June 4, 2019 10:57 AM
    Moderator