error on SERVICE_WIN32_SHARE_PROCESS

  • Thread starter Thread starter Marcel Serour
  • Start date Start date
M

Marcel Serour

I'm using c# and creating a proccess without problems using dllimport's,
I'm using this method instead of the service installer classes because I
found this way simplier

the problem is that even passing SERVICE_WIN32_SHARE_PROCESS as
argument, the service creates it's own proccess, and I don't want that
to happen, I want it to be on a thread
any ideas on why this may be happenning? or maybe some other idea to
hide my application?

thanks in advance
marcel
 
Marcel,

If you want something to execute on a different thread in the same
process, why not just use a Thread instance instead of a process instance?
 
Nicholas said:
Marcel,

If you want something to execute on a different thread in the same
process, why not just use a Thread instance instead of a process instance?
maybe I was't clear enough..

I am creating a service, windows is creating a proccess when I register
the service, not me
I want my service to run on a thread not a proccess
 
Marcel,

It does run on a thread, in the process that is dedicated for the
service. You can't have a service run in just a thread, a thread has to
have an associated process, and the service control manager does not handle
running tasks in it's own threads, it depends on services to run in their
own process.

After all, what if one of the services in a thread brought down the
whole process? Then other services would be impacted, and that's generally
not cool.
 
Multiple services can be hosted in the same process, see svchost.exe in
process explorer, most do run multiple system 'services'. And the framework
supports multiple service hosting as well.
Each of the services run on a separate thread (created by the framework
calling into the Win32 Service API) and they are managed by the SCM as if
they were running in separate processes, the SCM controls the service
instance through a named pipe connection with the service control thread
(also created by the framework calling into Win32's service API).
Note that services should be "bug free", that means that they should be
carefully designed and tested before you consider them to be solid service
candidates. Services that are multi-hosted should be designed to be "crash
free" and they should be able to recover from possible failures.

Willy.



Nicholas Paldino said:
Marcel,

It does run on a thread, in the process that is dedicated for the
service. You can't have a service run in just a thread, a thread has to
have an associated process, and the service control manager does not
handle running tasks in it's own threads, it depends on services to run in
their own process.

After all, what if one of the services in a thread brought down the
whole process? Then other services would be impacted, and that's
generally not cool.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Marcel Serour said:
maybe I was't clear enough..

I am creating a service, windows is creating a proccess when I register
the service, not me
I want my service to run on a thread not a proccess
 
Marcel Serour said:
I'm using c# and creating a proccess without problems using dllimport's,
I'm using this method instead of the service installer classes because I
found this way simplier

the problem is that even passing SERVICE_WIN32_SHARE_PROCESS as argument,
the service creates it's own proccess, and I don't want that to happen, I
want it to be on a thread
any ideas on why this may be happenning? or maybe some other idea to hide
my application?

thanks in advance
marcel

I suppose you are calling CreateService passing SERVICE_WIN32_SHARE_PROCESS
as service type do you?
How did you implement your service code? I guess you didn't use the
framework at all for this, and your service is a simple console exe, right?
Could you post your code?

Willy.
 
Willy said:
Multiple services can be hosted in the same process, see svchost.exe in
process explorer, most do run multiple system 'services'. And the framework
supports multiple service hosting as well.
Each of the services run on a separate thread (created by the framework
calling into the Win32 Service API) and they are managed by the SCM as if
they were running in separate processes, the SCM controls the service
instance through a named pipe connection with the service control thread
(also created by the framework calling into Win32's service API).
Note that services should be "bug free", that means that they should be
carefully designed and tested before you consider them to be solid service
candidates. Services that are multi-hosted should be designed to be "crash
free" and they should be able to recover from possible failures.

Willy.



Marcel,

It does run on a thread, in the process that is dedicated for the
service. You can't have a service run in just a thread, a thread has to
have an associated process, and the service control manager does not
handle running tasks in it's own threads, it depends on services to run in
their own process.

After all, what if one of the services in a thread brought down the
whole process? Then other services would be impacted, and that's
generally not cool.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Nicholas Paldino [.NET/C# MVP] wrote:

Marcel,

If you want something to execute on a different thread in the same
process, why not just use a Thread instance instead of a process
instance?



maybe I was't clear enough..

I am creating a service, windows is creating a proccess when I register
the service, not me
I want my service to run on a thread not a proccess
thanks for the explanation, but how can I do that?
 
Willy said:
I suppose you are calling CreateService passing SERVICE_WIN32_SHARE_PROCESS
as service type do you?
How did you implement your service code? I guess you didn't use the
framework at all for this, and your service is a simple console exe, right?
Could you post your code?

Willy.
my main is a console like..
static void Main(string[] args)
{
System.ServiceProcess.ServiceBase.Run(new Service());
}
where
public class Service : System.ServiceProcess.ServiceBase
{
}

do you want the code to install the service also?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top