471,337 Members | 1,102 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

error on SERVICE_WIN32_SHARE_PROCESS

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
Dec 22 '05 #1
7 1654
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 Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Marcel Serour" <ma****@kttf.net> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
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

Dec 22 '05 #2
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
Dec 22 '05 #3
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]
- mv*@spam.guard.caspershouse.com

"Marcel Serour" <ma****@kttf.net> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl...
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

Dec 22 '05 #4
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eO*************@tk2msftngp13.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Marcel Serour" <ma****@kttf.net> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl...
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


Dec 22 '05 #5

"Marcel Serour" <ma****@kttf.net> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
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.

Dec 22 '05 #6
Willy Denoyette [MVP] wrote:
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eO*************@tk2msftngp13.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"Marcel Serour" <ma****@kttf.net> wrote in message
news:Oz*************@tk2msftngp13.phx.gbl...
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?
Dec 23 '05 #7
Willy Denoyette [MVP] wrote:
"Marcel Serour" <ma****@kttf.net> wrote in message
news:ep**************@tk2msftngp13.phx.gbl...
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.

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?
Dec 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tony Wright | last post: by
1 post views Thread by Aravind | last post: by
1 post views Thread by yanwan | last post: by
5 posts views Thread by Enos Meroka | last post: by
7 posts views Thread by p | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.