Skip to Content
avatar image
Former Member

Converting Console App to Windows Service

I'm trying to convert a Console Application to a Windows Service, so I move the code from the Main procedure (in the Console App) to the OnStart event (in the Service). I set the account property to LocalSystem, put in the correct command line parameters and change the Startup object to the Service (instead of the main). I compile, install and start the service. I write to the event log to confirm the service is working properly. When I click the Test Connection button in SM59 I get the error that the program isn't registered. When I do this from the Console App everything work fine.

Any thoughts?

Thanks,

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jun 16, 2005 at 07:03 PM

    The problem was resolved by using the same name for the Prog ID and for the EXE. I also moved the command line parameters into the application code (which might have fixed the issue).

    Thanks for your help,

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 11, 2005 at 08:43 AM

    The process which windows service running in, is different with the process our console running in.

    Are you check the return result of the RFC host register calling in your windows service?

    Is there any unnormal return code?

    Add comment
    10|10000 characters needed characters exceeded

    • Another important point it the command line: You should know that services have two command lines: One written in the registry and passed to the Main function (that is usually hidden in the framework). The other is the one passed to OnStart(). This one is really unusual: You have to type these parameters in the manual start dialog of the Services MMC. So you better don't use is and take your paramters from somewhere else.

  • avatar image
    Former Member
    Jun 13, 2005 at 02:47 PM

    Yeah, I agree the above reply.

    And I think you can just deploy a windows service to have a test. If all of the service action goes well, then add the code about dotnet connector to it, test further.

    Though this step, you can clearly detect where the error is, what due to it.

    hope it will be useful

    Add comment
    10|10000 characters needed characters exceeded