473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Services..

I created a console app, but most all the code was in classes. I've
recently created a windows service, pulled all the classes over and
everything compiles fine.

Few things I need to understand though. I'm a C++ guy so this service is
much different to me.

1) Where do I spawn the main thread off from?
(a) My first guess is in the Program.cs in the Main() before the
ServiceBase.Run(). However, that doesn't seem right because if I'm only
registering it, then I don't want my service to start processing only
register.
(b) My second guess would be after the ServiceBase.Run(), However
that should stop within Run and never get my thread started.

2) How do I register this service under Windows Services?
(a) In C++ it was just "ExeName.exe /Service". After digging
around I found some Mono code that represents what C# does and it was using
/Install. However it doesn't seem to work, instead I get errors saying I
need to run InstallUtil.exe. I looked at InstallUtil.exe and ran it
against my exe it seems to run successfully, but out side of created 2 more
files, it didn't seem to do anything.
(b) Once I get it install I'll need to know how to remove it from
services, like /UnRegservice does in C++.

3) How to add an icon to my service?
(a) I created a resource file with an icon, but it seems to be
ignoring the icon.
Jan 9 '08 #1
23 1553

"Chizl" <Ch***@NoShitMail.comwrote in message
news:u2**************@TK2MSFTNGP05.phx.gbl...
>I created a console app, but most all the code was in classes. I've
recently created a windows service, pulled all the classes over and
everything compiles fine.

Few things I need to understand though. I'm a C++ guy so this service is
much different to me.

1) Where do I spawn the main thread off from?
(a) My first guess is in the Program.cs in the Main() before the
ServiceBase.Run(). However, that doesn't seem right because if I'm only
registering it, then I don't want my service to start processing only
register.
(b) My second guess would be after the ServiceBase.Run(), However
that should stop within Run and never get my thread started.
The main thread is the thread the application started up on. You spawn child
threads off of the main thread during the OnStart() event, using a delgate
method that a Thread.Start is using, as an example.
>
2) How do I register this service under Windows Services?
(a) In C++ it was just "ExeName.exe /Service". After digging
around I found some Mono code that represents what C# does and it was
using /Install. However it doesn't seem to work, instead I get errors
saying I need to run InstallUtil.exe. I looked at InstallUtil.exe and
ran it against my exe it seems to run successfully, but out side of
created 2 more files, it didn't seem to do anything.
You use Installutil servcename.exe to install the service.
(b) Once I get it install I'll need to know how to remove it from
services, like /UnRegservice does in C++.
You use InstallUtil -u servicename.exe.
>
3) How to add an icon to my service?
(a) I created a resource file with an icon, but it seems to be
ignoring the icon.
You can use Google look it up. I am sure you'll find an example.

Jan 10 '08 #2
Yea, I figured out the icon by mistake going through the properties of the
project.. All I had to do is select it..
I did a search to find OnStart, I had never seen it.. Seems it's the .cs
that I double click and it shows me a properties page instead of the actual
code.

However the Installation is still a problem. I run "installutil
myexe.exe", it says success. From what I read it say I then just do a "net
start <service name>" That a problem, because before I can do that, should I
see the service in my service manager? It's not there.

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>
"Chizl" <Ch***@NoShitMail.comwrote in message
news:u2**************@TK2MSFTNGP05.phx.gbl...
>>I created a console app, but most all the code was in classes. I've
recently created a windows service, pulled all the classes over and
everything compiles fine.

Few things I need to understand though. I'm a C++ guy so this service is
much different to me.

1) Where do I spawn the main thread off from?
(a) My first guess is in the Program.cs in the Main() before the
ServiceBase.Run(). However, that doesn't seem right because if I'm only
registering it, then I don't want my service to start processing only
register.
(b) My second guess would be after the ServiceBase.Run(), However
that should stop within Run and never get my thread started.

The main thread is the thread the application started up on. You spawn
child threads off of the main thread during the OnStart() event, using a
delgate method that a Thread.Start is using, as an example.
>>
2) How do I register this service under Windows Services?
(a) In C++ it was just "ExeName.exe /Service". After digging
around I found some Mono code that represents what C# does and it was
using /Install. However it doesn't seem to work, instead I get errors
saying I need to run InstallUtil.exe. I looked at InstallUtil.exe and
ran it against my exe it seems to run successfully, but out side of
created 2 more files, it didn't seem to do anything.

You use Installutil servcename.exe to install the service.
> (b) Once I get it install I'll need to know how to remove it from
services, like /UnRegservice does in C++.

You use InstallUtil -u servicename.exe.
>>
3) How to add an icon to my service?
(a) I created a resource file with an icon, but it seems to be
ignoring the icon.

You can use Google look it up. I am sure you'll find an example.

Jan 10 '08 #3

"Chizl" <Ch***@NoShitMail.comwrote in message
news:e7**************@TK2MSFTNGP05.phx.gbl...
Yea, I figured out the icon by mistake going through the properties of the
project.. All I had to do is select it..
I did a search to find OnStart, I had never seen it.. Seems it's the .cs
that I double click and it shows me a properties page instead of the
actual code.
You should be able to see the code of the OnStart(), at least, the place
holder code that is places there for each of the Service code events if you
use one of them.. Maybe, you need to right-click and do a View Code.
>
However the Installation is still a problem. I run "installutil
myexe.exe", it says success. From what I read it say I then just do a
"net start <service name>" That a problem, because before I can do that,
should I see the service in my service manager? It's not there.
If you don't see the Service listed off of Control Panel/Admin
Tools/Services, then you can do a reboot to see if it shows.
>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>>
"Chizl" <Ch***@NoShitMail.comwrote in message
news:u2**************@TK2MSFTNGP05.phx.gbl...
>>>I created a console app, but most all the code was in classes. I've
recently created a windows service, pulled all the classes over and
everything compiles fine.

Few things I need to understand though. I'm a C++ guy so this service
is much different to me.

1) Where do I spawn the main thread off from?
(a) My first guess is in the Program.cs in the Main() before the
ServiceBase.Run(). However, that doesn't seem right because if I'm only
registering it, then I don't want my service to start processing only
register.
(b) My second guess would be after the ServiceBase.Run(), However
that should stop within Run and never get my thread started.

The main thread is the thread the application started up on. You spawn
child threads off of the main thread during the OnStart() event, using a
delgate method that a Thread.Start is using, as an example.
>>>
2) How do I register this service under Windows Services?
(a) In C++ it was just "ExeName.exe /Service". After digging
around I found some Mono code that represents what C# does and it was
using /Install. However it doesn't seem to work, instead I get errors
saying I need to run InstallUtil.exe. I looked at InstallUtil.exe and
ran it against my exe it seems to run successfully, but out side of
created 2 more files, it didn't seem to do anything.

You use Installutil servcename.exe to install the service.
>> (b) Once I get it install I'll need to know how to remove it from
services, like /UnRegservice does in C++.

You use InstallUtil -u servicename.exe.
>>>
3) How to add an icon to my service?
(a) I created a resource file with an icon, but it seems to be
ignoring the icon.

You can use Google look it up. I am sure you'll find an example.

Jan 10 '08 #4
I've created a new project, Window Service, nothing in it at all, run
InstallUtil on the test.exe and it doesnt do anything..

Maybe it's my version.. I'm using Visual Studio 2008 which uses Framework
v3.5. However I noticed that the only InstallUtil I have is for 1.1 and
2.0, there wasn't one for 3.0 or 3.5..

"Chizl" <Ch***@NoShitMail.comwrote in message
news:e7**************@TK2MSFTNGP05.phx.gbl...
Yea, I figured out the icon by mistake going through the properties of the
project.. All I had to do is select it..
I did a search to find OnStart, I had never seen it.. Seems it's the .cs
that I double click and it shows me a properties page instead of the
actual code.

However the Installation is still a problem. I run "installutil
myexe.exe", it says success. From what I read it say I then just do a
"net start <service name>" That a problem, because before I can do that,
should I see the service in my service manager? It's not there.

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...
>>
"Chizl" <Ch***@NoShitMail.comwrote in message
news:u2**************@TK2MSFTNGP05.phx.gbl...
>>>I created a console app, but most all the code was in classes. I've
recently created a windows service, pulled all the classes over and
everything compiles fine.

Few things I need to understand though. I'm a C++ guy so this service
is much different to me.

1) Where do I spawn the main thread off from?
(a) My first guess is in the Program.cs in the Main() before the
ServiceBase.Run(). However, that doesn't seem right because if I'm only
registering it, then I don't want my service to start processing only
register.
(b) My second guess would be after the ServiceBase.Run(), However
that should stop within Run and never get my thread started.

The main thread is the thread the application started up on. You spawn
child threads off of the main thread during the OnStart() event, using a
delgate method that a Thread.Start is using, as an example.
>>>
2) How do I register this service under Windows Services?
(a) In C++ it was just "ExeName.exe /Service". After digging
around I found some Mono code that represents what C# does and it was
using /Install. However it doesn't seem to work, instead I get errors
saying I need to run InstallUtil.exe. I looked at InstallUtil.exe and
ran it against my exe it seems to run successfully, but out side of
created 2 more files, it didn't seem to do anything.

You use Installutil servcename.exe to install the service.
>> (b) Once I get it install I'll need to know how to remove it from
services, like /UnRegservice does in C++.

You use InstallUtil -u servicename.exe.
>>>
3) How to add an icon to my service?
(a) I created a resource file with an icon, but it seems to be
ignoring the icon.

You can use Google look it up. I am sure you'll find an example.


Jan 11 '08 #5
"Chizl" <Ch***@NoShitMail.comwrote in message
news:eg****************@TK2MSFTNGP05.phx.gbl...
I've created a new project, Window Service, nothing in it at all, run
InstallUtil on the test.exe and it doesnt do anything..

Maybe it's my version.. I'm using Visual Studio 2008 which uses Framework
v3.5. However I noticed that the only InstallUtil I have is for 1.1 and
2.0, there wasn't one for 3.0 or 3.5..
Your service project is incomplete, you are missing the Installer stuff.
Search the docs (MSDN), it should have a Windows Services tutorial.

Willy.

Jan 11 '08 #6
I have and I'm still not getting it.. I can get it to show up in the
Service Manager now, but when I run it, it's like it never starts it..
Service Manager says it's running, the event log says its running. I have
Log writes I do in Main() and it never writes anything.. Only in service
mode.. If I hit F5 I get the log file info just fine.. Since Main is the
first thing that starts, I'm confused of why it would not execute the first
line which is my Log write..
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:e7****************@TK2MSFTNGP04.phx.gbl...
"Chizl" <Ch***@NoShitMail.comwrote in message
news:eg****************@TK2MSFTNGP05.phx.gbl...
>I've created a new project, Window Service, nothing in it at all, run
InstallUtil on the test.exe and it doesnt do anything..

Maybe it's my version.. I'm using Visual Studio 2008 which uses
Framework v3.5. However I noticed that the only InstallUtil I have is
for 1.1 and 2.0, there wasn't one for 3.0 or 3.5..

Your service project is incomplete, you are missing the Installer stuff.
Search the docs (MSDN), it should have a Windows Services tutorial.

Willy.

Jan 12 '08 #7
This is getting insanely annoying.. I'm missing something simple and I've
been all:
http://msdn2.microsoft.com/en-us/lib...83(VS.71).aspx
http://www.developer.com/net/csharp/...0918_2173801_1
http://www.c-sharpcorner.com/UploadF...w_service.aspx

Based on MS the basics is:
ServiceName, I have..
Installers, I have..
Override the OnStart, I have..

Main is acting as if it's not being called when running as a service and I'm
about go back to C++.. Seems kind of stupid, I click on "Windows Service"
and then I have to add all the service components to make it work.. Why
isn't that by default!!?? The parts of it being a service, is something MS
does anyway, I'm just naming it, give it a description, and threading it off
to my function so it can wait for windows messages..
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:e7****************@TK2MSFTNGP04.phx.gbl...
"Chizl" <Ch***@NoShitMail.comwrote in message
news:eg****************@TK2MSFTNGP05.phx.gbl...
>I've created a new project, Window Service, nothing in it at all, run
InstallUtil on the test.exe and it doesnt do anything..

Maybe it's my version.. I'm using Visual Studio 2008 which uses
Framework v3.5. However I noticed that the only InstallUtil I have is
for 1.1 and 2.0, there wasn't one for 3.0 or 3.5..

Your service project is incomplete, you are missing the Installer stuff.
Search the docs (MSDN), it should have a Windows Services tutorial.

Willy.

Jan 12 '08 #8
"Chizl" <Ch***@NoShitMail.comwrote in message
news:u3**************@TK2MSFTNGP06.phx.gbl...
>I have and I'm still not getting it.. I can get it to show up in the
Service Manager now, but when I run it, it's like it never starts it..
Service Manager says it's running, the event log says its running. I have
Log writes I do in Main() and it never writes anything.. Only in service
mode.. If I hit F5 I get the log file info just fine.. Since Main is
the first thing that starts, I'm confused of why it would not execute the
first line which is my Log write..
If the Service Manager says it's running, it means that "OnStart" has been
called and returned successfully in a timely fashion.
That would mean that there should be at least an information message in the
Application log that reads like:
Service started succesfully.
with the Source set to your "service name", this message is logged by the
SCM after your OnStart returned.
If you are writing to the eventlog from your Main, you should see this
message in the eventlog before the above message.
If you see the SCM message but not your own message, there must be something
wrong with your code that logs to the eventlog.

Willy.


Jan 12 '08 #9

"Chizl" <Ch***@NoShitMail.comwrote in message
news:Ov**************@TK2MSFTNGP04.phx.gbl...
This is getting insanely annoying.. I'm missing something simple and
I've been all:
http://msdn2.microsoft.com/en-us/lib...83(VS.71).aspx
http://www.developer.com/net/csharp/...0918_2173801_1
http://www.c-sharpcorner.com/UploadF...w_service.aspx

Based on MS the basics is:
ServiceName, I have..
Installers, I have..
Override the OnStart, I have..

Main is acting as if it's not being called when running as a service and
I'm about go back to C++.. Seems kind of stupid, I click on "Windows
Service" and then I have to add all the service components to make it
work.. Why isn't that by default!!?? The parts of it being a service, is
something MS does anyway, I'm just naming it, give it a description, and
threading it off to my function so it can wait for windows messages..
You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it work.

And as far as something being the default, it is what it is, and there is
nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need to do
some try/catch(s) with an Eventlog or dumping of messages in an Eventlog to
tell you where you're at in code. Maybe, if you're developing on a non
Vista NT based O/S, then you can do a NetSend with a messages in code to
tell you where you're at in the code.

Jan 12 '08 #10

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
>
You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it
work.

And as far as something being the default, it is what it is, and there is
nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need to
do some try/catch(s) with an Eventlog or dumping of messages in an
Eventlog to tell you where you're at in code. Maybe, if you're developing
on a non Vista NT based O/S, then you can do a NetSend with a messages in
code to tell you where you're at in the code.

I'm running on XP Pro with the latest SP.. I'm one of the Vista users that
went back to XP.. I tried for 9 months and finally gave up.

Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but I'm
not doing anything in ProjectInstaller() method.. Am I supposed to?
Based on posts and reading, the OnStart which is in the Service1.cs is where
I'm supposed to thread off. This however is never being called.

I created a bare demo that has nothing in it, but the defaults, added the
installer, added a class I can thread off to.
Here is that code:
Here are my logs..

Hitting F5, I get the error it's a service and cant be run, bla, bla, bla..
Understandable..
2008-01-12 17:34:32:7656,Program.cs->Main() Called
2008-01-12 17:34:32:7656,Service1.cs->Service1() Called
2008-01-12 17:34:32:7656,Program.cs->ServiceBase.Run() Calling
2008-01-12 17:34:34:2500,Program.cs->ServiceBase.Run() Returned
2008-01-12 17:34:34:2500,Program.cs->Main() Leaving

When I run under a service mode, this is all I get..
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Called
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Leaving
Jan 13 '08 #11
That's weird my link was removed.. It was a link to my website, which is a
zip file.. Zip of the solution.. Trying again..

Remove the space before WinSrvsTest.zip..
http://www.chizl.com/aspuploaded/ WinSrvsTest.zip
"Chizl" <Ch***@NoShitMail.comwrote in message
news:ua**************@TK2MSFTNGP06.phx.gbl...
>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
>>
You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it
work.

And as far as something being the default, it is what it is, and there is
nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need to
do some try/catch(s) with an Eventlog or dumping of messages in an
Eventlog to tell you where you're at in code. Maybe, if you're
developing on a non Vista NT based O/S, then you can do a NetSend with a
messages in code to tell you where you're at in the code.


I'm running on XP Pro with the latest SP.. I'm one of the Vista users
that went back to XP.. I tried for 9 months and finally gave up.

Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but
I'm not doing anything in ProjectInstaller() method.. Am I supposed to?
Based on posts and reading, the OnStart which is in the Service1.cs is
where I'm supposed to thread off. This however is never being called.

I created a bare demo that has nothing in it, but the defaults, added the
installer, added a class I can thread off to.
Here is that code:
Here are my logs..

Hitting F5, I get the error it's a service and cant be run, bla, bla,
bla.. Understandable..
2008-01-12 17:34:32:7656,Program.cs->Main() Called
2008-01-12 17:34:32:7656,Service1.cs->Service1() Called
2008-01-12 17:34:32:7656,Program.cs->ServiceBase.Run() Calling
2008-01-12 17:34:34:2500,Program.cs->ServiceBase.Run() Returned
2008-01-12 17:34:34:2500,Program.cs->Main() Leaving

When I run under a service mode, this is all I get..
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Called
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Leaving

Jan 13 '08 #12
Does anyone have a sample bare service written in C# 2008? All the samples
I find, put 1000 other things into it, I cant tell what is required for the
service and what is some thing they are doing.

I've gotten my webserver to process 721 requests per seconds. 86538 hits
in 2 minutes. It really sucks I get this far and cant get the stupid thing
to run as a service.

http://70.136.66.85/StressTest.txt

"Chizl" <Ch***@NoShitMail.comwrote in message
news:OP**************@TK2MSFTNGP03.phx.gbl...
That's weird my link was removed.. It was a link to my website, which is
a zip file.. Zip of the solution.. Trying again..

Remove the space before WinSrvsTest.zip..
http://www.chizl.com/aspuploaded/ WinSrvsTest.zip
"Chizl" <Ch***@NoShitMail.comwrote in message
news:ua**************@TK2MSFTNGP06.phx.gbl...
>>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
>>>
You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it
work.

And as far as something being the default, it is what it is, and there
is nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need to
do some try/catch(s) with an Eventlog or dumping of messages in an
Eventlog to tell you where you're at in code. Maybe, if you're
developing on a non Vista NT based O/S, then you can do a NetSend with a
messages in code to tell you where you're at in the code.


I'm running on XP Pro with the latest SP.. I'm one of the Vista users
that went back to XP.. I tried for 9 months and finally gave up.

Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but
I'm not doing anything in ProjectInstaller() method.. Am I supposed to?
Based on posts and reading, the OnStart which is in the Service1.cs is
where I'm supposed to thread off. This however is never being called.

I created a bare demo that has nothing in it, but the defaults, added the
installer, added a class I can thread off to.
Here is that code:
Here are my logs..

Hitting F5, I get the error it's a service and cant be run, bla, bla,
bla.. Understandable..
2008-01-12 17:34:32:7656,Program.cs->Main() Called
2008-01-12 17:34:32:7656,Service1.cs->Service1() Called
2008-01-12 17:34:32:7656,Program.cs->ServiceBase.Run() Calling
2008-01-12 17:34:34:2500,Program.cs->ServiceBase.Run() Returned
2008-01-12 17:34:34:2500,Program.cs->Main() Leaving

When I run under a service mode, this is all I get..
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Called
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Leaving


Jan 13 '08 #13
The service gets started, take a look in the eventlog you will see a message
that it was started. Like I said before OnStart is called otherwise your
service would not enter the running state.
The problem is with your logging code, you are writing to the console
window, but a service has NO console window attached, so your messages are
going nowhere. You should log to a file or the eventlog or use a trace
listener that logs to a debugger.

Willy.


"Chizl" <Ch***@NoShitMail.comschreef in bericht
news:OP**************@TK2MSFTNGP03.phx.gbl...
That's weird my link was removed.. It was a link to my website, which is
a zip file.. Zip of the solution.. Trying again..

Remove the space before WinSrvsTest.zip..
http://www.chizl.com/aspuploaded/ WinSrvsTest.zip
"Chizl" <Ch***@NoShitMail.comwrote in message
news:ua**************@TK2MSFTNGP06.phx.gbl...
>>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...
>>>
You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it
work.

And as far as something being the default, it is what it is, and there
is nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need to
do some try/catch(s) with an Eventlog or dumping of messages in an
Eventlog to tell you where you're at in code. Maybe, if you're
developing on a non Vista NT based O/S, then you can do a NetSend with a
messages in code to tell you where you're at in the code.


I'm running on XP Pro with the latest SP.. I'm one of the Vista users
that went back to XP.. I tried for 9 months and finally gave up.

Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but
I'm not doing anything in ProjectInstaller() method.. Am I supposed to?
Based on posts and reading, the OnStart which is in the Service1.cs is
where I'm supposed to thread off. This however is never being called.

I created a bare demo that has nothing in it, but the defaults, added the
installer, added a class I can thread off to.
Here is that code:
Here are my logs..

Hitting F5, I get the error it's a service and cant be run, bla, bla,
bla.. Understandable..
2008-01-12 17:34:32:7656,Program.cs->Main() Called
2008-01-12 17:34:32:7656,Service1.cs->Service1() Called
2008-01-12 17:34:32:7656,Program.cs->ServiceBase.Run() Calling
2008-01-12 17:34:34:2500,Program.cs->ServiceBase.Run() Returned
2008-01-12 17:34:34:2500,Program.cs->Main() Leaving

When I run under a service mode, this is all I get..
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Called
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Leaving

Jan 13 '08 #14

"Chizl" <Ch***@NoShitMail.comwrote in message
news:ua**************@TK2MSFTNGP06.phx.gbl...
>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
<snipped>
Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but
I'm
I have never used the ProjectInstaller.cs You don't needed in the project,
really. And maybe, that's your problem. I think most people use it, because
it allows one to install a logfile that an Eventlog will use, and maybe,
some other stuff along those lines.

But once I found out that I can create a Eventlog in code and hook the
application to the Eventlog on the fly, I had no more use for the
ProjectInstaller.cs. The Createventlog() is in the Onstart(). :)
Jan 13 '08 #15
My TRACE writes to file as well, guess you missed that.. It's running, but
never hitting OnStart..

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
The service gets started, take a look in the eventlog you will see a
message that it was started. Like I said before OnStart is called
otherwise your service would not enter the running state.
The problem is with your logging code, you are writing to the console
window, but a service has NO console window attached, so your messages are
going nowhere. You should log to a file or the eventlog or use a trace
listener that logs to a debugger.

Willy.


"Chizl" <Ch***@NoShitMail.comschreef in bericht
news:OP**************@TK2MSFTNGP03.phx.gbl...
>That's weird my link was removed.. It was a link to my website, which
is a zip file.. Zip of the solution.. Trying again..

Remove the space before WinSrvsTest.zip..
http://www.chizl.com/aspuploaded/ WinSrvsTest.zip
"Chizl" <Ch***@NoShitMail.comwrote in message
news:ua**************@TK2MSFTNGP06.phx.gbl...
>>>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uB**************@TK2MSFTNGP02.phx.gbl...

You can roll your on too.

http://www.dotnetzone.gr/cs/blogs/sf...cles/5484.aspx

BTW, what O/S platform are you trying to develop this on?

You mention VS 2008. Maybe, you need to fallback to VS 2005 to see it
work.

And as far as something being the default, it is what it is, and there
is nothing you can do about it -- work with it.

It also sounds like it has blown up and you don't know that it has done
that. You can't debug the Onstart() with the debugger. Maybe you need
to do some try/catch(s) with an Eventlog or dumping of messages in an
Eventlog to tell you where you're at in code. Maybe, if you're
developing on a non Vista NT based O/S, then you can do a NetSend with
a messages in code to tell you where you're at in the code.

I'm running on XP Pro with the latest SP.. I'm one of the Vista users
that went back to XP.. I tried for 9 months and finally gave up.

Here is what I figured out since my last post.. I found that under
ProjectInstaller.cs, the ProjectInstaller() method is being called, but
I'm not doing anything in ProjectInstaller() method.. Am I supposed
to? Based on posts and reading, the OnStart which is in the Service1.cs
is where I'm supposed to thread off. This however is never being
called.

I created a bare demo that has nothing in it, but the defaults, added
the installer, added a class I can thread off to.
Here is that code:
Here are my logs..

Hitting F5, I get the error it's a service and cant be run, bla, bla,
bla.. Understandable..
2008-01-12 17:34:32:7656,Program.cs->Main() Called
2008-01-12 17:34:32:7656,Service1.cs->Service1() Called
2008-01-12 17:34:32:7656,Program.cs->ServiceBase.Run() Calling
2008-01-12 17:34:34:2500,Program.cs->ServiceBase.Run() Returned
2008-01-12 17:34:34:2500,Program.cs->Main() Leaving

When I run under a service mode, this is all I get..
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Called
2008-01-12 17:36:12:1093,ProjectInstaller.cs->ProjectInstaller() Leaving


Jan 13 '08 #16

"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>
I have never used the ProjectInstaller.cs You don't needed in the project,
really. And maybe, that's your problem. I think most people use it,
because it allows one to install a logfile that an Eventlog will use, and
maybe, some other stuff along those lines.

But once I found out that I can create a Eventlog in code and hook the
application to the Eventlog on the fly, I had no more use for the
ProjectInstaller.cs. The Createventlog() is in the Onstart(). :)
When I add an installer of which MS tells me I have to do, it creates the
ProjectInstaller.cs.. If there is a better way, please elaborate.. I
just want this to run as a service, I don't really care how at this point.
Jan 13 '08 #17

"Chizl" <Ch***@NoShitMail.comwrote in message
news:en**************@TK2MSFTNGP05.phx.gbl...
>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>
I have never used the ProjectInstaller.cs You don't needed in the
project, really. And maybe, that's your problem. I think most people use
it, because it allows one to install a logfile that an Eventlog will use,
and maybe, some other stuff along those lines.

But once I found out that I can create a Eventlog in code and hook the
application to the Eventlog on the fly, I had no more use for the
ProjectInstaller.cs. The Createventlog() is in the Onstart(). :)

When I add an installer of which MS tells me I have to do, it creates the
ProjectInstaller.cs.. If there is a better way, please elaborate.. I
just want this to run as a service, I don't really care how at this point.
As you see in the two examples, there is no talk about the
Projectinstall.cs. You don't need it. You simply create your Windows Service
project without the ProjectInstaller.cs, build the exe, and you use
InstallUtil to install the service.exe.

Now, if you have to use a ProjectInstaller.cs, then by all means use it. But
it doesn't mean that you have to use it.

http://www.aspfree.com/c/a/C-Sharp/C...-introduction/
http://www.vbdotnetheaven.com/Upload...Winservvb.aspx

Jan 14 '08 #18
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:u8**************@TK2MSFTNGP05.phx.gbl...
>>>
What's wrong writing to his own System Application Eventlog?
Nothing, but this is not what the OP is doing, he's writing to a regular
file not to the Eventlog.

He should dump it or use the Application Block to write to a log file.
When I stress test, I'm writing over 80,000 to the log.. This is a web
server that logs everything. EventLog is not meant for that.

I see what your saying about it's not a relative path.. I've also noticed,
I'm using / instead of \ so that I can compile this under Mono for
CrossPlatform development, but seems as a service, it's having a problem
with it..

I added: System.Diagnostics.Debugger.Launch(); so I could start walking
through the service and there is all kinds of path issues I have to resolve
so that it will run as a service..

What is the best way to get Local Path? I'm using:
System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetExecutingAssembly().GetName().CodeBase );
However, that returns file:// in front of it.. Is there a faster or better
way?
Jan 15 '08 #19
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:uX**************@TK2MSFTNGP03.phx.gbl...
>
"Chizl" <Ch***@NoShitMail.comwrote in message
news:en**************@TK2MSFTNGP05.phx.gbl...
>>
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>>
I have never used the ProjectInstaller.cs You don't needed in the
project, really. And maybe, that's your problem. I think most people use
it, because it allows one to install a logfile that an Eventlog will
use, and maybe, some other stuff along those lines.

But once I found out that I can create a Eventlog in code and hook the
application to the Eventlog on the fly, I had no more use for the
ProjectInstaller.cs. The Createventlog() is in the Onstart(). :)

When I add an installer of which MS tells me I have to do, it creates the
ProjectInstaller.cs.. If there is a better way, please elaborate.. I
just want this to run as a service, I don't really care how at this
point.

As you see in the two examples, there is no talk about the
Projectinstall.cs. You don't need it. You simply create your Windows
Service project without the ProjectInstaller.cs, build the exe, and you
use InstallUtil to install the service.exe.

Now, if you have to use a ProjectInstaller.cs, then by all means use it.
But it doesn't mean that you have to use it.

http://www.aspfree.com/c/a/C-Sharp/C...-introduction/
http://www.vbdotnetheaven.com/Upload...Winservvb.aspx
Thanks, I appreciate all the help, thus far.. Banging my head on the
desk, since this is the thing out of all the stuff I've done that doesn't
want to work..
Jan 15 '08 #20
I have a SERVICE!!! WOOT!! It had to do with all the path issues, which
finding the debug call while running as a service helped a lot.. I want to
thank both Willy and Mr. Arnald.. You guys rock..

But with all this, I think that kind of sucks.. Running as a service
doesn't use the same path methods as an application. It's almost as if two
different departments wrote C# at MS.

Thanks again..

--
/*Chizl*/
Jan 15 '08 #21
"Chizl" <Ch***@NoShitMail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I have a SERVICE!!! WOOT!! It had to do with all the path issues, which
finding the debug call while running as a service helped a lot.. I want to
thank both Willy and Mr. Arnald.. You guys rock..

But with all this, I think that kind of sucks.. Running as a service
doesn't use the same path methods as an application. It's almost as if
two different departments wrote C# at MS.
This has absolutely nothing to do with C#, this is how Windows and Windows
Services work, the implementation language is not relevant. Window Services
must adhere to the rules imposed by the SCM, who's the parent process of all
Services. And as it goes with all processes in windows, your Service
inherits it's environment from it's parent (the SCM) which is not the same
as the environment of a process launched from a command shell or the
interactive shell (explorer for instance). Note also that services do not
have a profile loaded, cannot (by default) access the visible desktop, nor
do they run in the same security context as an interactive logon session
(which may or may not be present). Services are background tasks (similar to
daemons on **ix), they may run in their own process, or they may share a
process with other services, mostly started at boot time and running till
shutdown, they have a dedicated task to accomplish, and because of their
nature, they must be as robust as possible (especially when they share a
process with others).

Willy.

Jan 15 '08 #22

"Chizl" <Ch***@NoShitMail.comwrote in message
news:ek**************@TK2MSFTNGP04.phx.gbl...
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:u8**************@TK2MSFTNGP05.phx.gbl...
>>>>
What's wrong writing to his own System Application Eventlog?

Nothing, but this is not what the OP is doing, he's writing to a regular
file not to the Eventlog.

He should dump it or use the Application Block to write to a log file.

When I stress test, I'm writing over 80,000 to the log.. This is a web
server that logs everything. EventLog is not meant for that.
Why reinvent the wheel? There is a whole section about using the
Application Blocks' logging abilities.

<http://www.microsoft.com/downloads/details.aspx?FamilyID=5A14E870-406B-4F2A-B723-97BA84AE80B5&displaylang=en>

>
I see what your saying about it's not a relative path.. I've also
noticed, I'm using / instead of \ so that I can compile this under Mono
for CrossPlatform development, but seems as a service, it's having a
problem with it..

I added: System.Diagnostics.Debugger.Launch(); so I could start walking
through the service and there is all kinds of path issues I have to
resolve so that it will run as a service..

What is the best way to get Local Path? I'm using:
System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetExecutingAssembly().GetName().CodeBase );
However, that returns file:// in front of it.. Is there a faster or
better
Well, I think that's what I use. So you make a String Function that returns
what you want out of the string path. :)

Jan 15 '08 #23
"Mr. Arnold" <MR. Ar****@Arnold.comwrote in message
news:eA**************@TK2MSFTNGP04.phx.gbl...
>
"Chizl" <Ch***@NoShitMail.comwrote in message
>What is the best way to get Local Path? I'm using:
System.IO.Path.GetDirectoryName(System.Reflection .Assembly.GetExecutingAssembly().GetName().CodeBas e);
However, that returns file:// in front of it.. Is there a faster or
better

Well, I think that's what I use. So you make a String Function that
returns what you want out of the string path. :)
What I ended up doing is creating a static property that stores this info in
a var, so I'm not executing the same IO.Path each time..

public static String AppPath
{
get { return m_szAppPath; }
set { m_szAppPath = value; }
}
Jan 16 '08 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rbt | last post by:
How does one associate a "Description" with a Windows service written in Python? I've just started experimenting with Python services. Here's my code... copied straight from Mr. Hammond's "Python...
6
by: cs | last post by:
I noticed there is some .net services on my winxp. One or two mention the CLR. Does that mean that my .net apps/services wont run before those services start? I need to run my service as early on...
0
by: Diego F. | last post by:
I've been days with that. I'm trying to work with web services sending and returning objects, and the web service must store some objects. - My first try (the most obvious in my opinion) was to use...
26
by: Mr Newbie | last post by:
What do I need to run a web service on my PC ? I know I need the .NET Framework, but do I need IIS Running ?
3
by: Matt D | last post by:
I've got two web services that use the same data types and that clients will have to consume. I read the msdn article on sharing types...
7
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
2
by: sdstraub | last post by:
I have created 5 services in my project, in the 1st service I set servicestorun = array of all 5 services, I have a project installer with 5 service installers, one for each service. I have code...
0
by: krishnaraju | last post by:
HI to all, please help me.its urgent requirement. my question is this is the wsdl file i got from our client.please see at bottom. when iam trying to access that webmethods iam getting...
1
by: Data Entry Outsourcing | last post by:
Data Entry plays vital role in every business area. Data Entry is one such aspects of any business that needs to be handled properly for expanding your business. Data Entry is one of the leading...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.