cancel
Showing results for 
Search instead for 
Did you mean: 

Converting Console App to Windows Service

Former Member
0 Kudos

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,

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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,

Former Member
0 Kudos

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

Former Member
0 Kudos

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?

reiner_hille-doering
Active Contributor
0 Kudos

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.