Services..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chizl

    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.ex e /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.


  • Mr. Arnold

    #2
    Re: Services..


    "Chizl" <Chizl@NoShitMa il.comwrote in message
    news:u2d0OnxUIH A.1212@TK2MSFTN GP05.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.ex e /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.

    Comment

    • Chizl

      #3
      Re: Services..

      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 "installuti l
      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. Arnold@Arnold.c omwrote in message
      news:OkZX01xUIH A.5132@TK2MSFTN GP02.phx.gbl...
      >
      "Chizl" <Chizl@NoShitMa il.comwrote in message
      news:u2d0OnxUIH A.1212@TK2MSFTN GP05.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.Ru n(). 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.ex e /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.
      >

      Comment

      • Mr. Arnold

        #4
        Re: Services..


        "Chizl" <Chizl@NoShitMa il.comwrote in message
        news:e7hxTI0UIH A.1212@TK2MSFTN GP05.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 "installuti l
        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. Arnold@Arnold.c omwrote in message
        news:OkZX01xUIH A.5132@TK2MSFTN GP02.phx.gbl...
        >>
        >"Chizl" <Chizl@NoShitMa il.comwrote in message
        >news:u2d0OnxUI HA.1212@TK2MSFT NGP05.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.R un(). 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.ex e /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.
        >>
        >
        >

        Comment

        • Chizl

          #5
          Re: Services..

          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" <Chizl@NoShitMa il.comwrote in message
          news:e7hxTI0UIH A.1212@TK2MSFTN GP05.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 "installuti l
          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. Arnold@Arnold.c omwrote in message
          news:OkZX01xUIH A.5132@TK2MSFTN GP02.phx.gbl...
          >>
          >"Chizl" <Chizl@NoShitMa il.comwrote in message
          >news:u2d0OnxUI HA.1212@TK2MSFT NGP05.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.R un(). 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.ex e /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.
          >>
          >
          >

          Comment

          • Willy Denoyette [MVP]

            #6
            Re: Services..

            "Chizl" <Chizl@NoShitMa il.comwrote in message
            news:egTEHx%23U IHA.5596@TK2MSF TNGP05.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.

            Comment

            • Chizl

              #7
              Re: Services..

              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]" <willy.denoyett e@telenet.bewro te in message
              news:e790%234DV IHA.5980@TK2MSF TNGP04.phx.gbl. ..
              "Chizl" <Chizl@NoShitMa il.comwrote in message
              news:egTEHx%23U IHA.5596@TK2MSF TNGP05.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.

              Comment

              • Chizl

                #8
                Re: Services..

                This is getting insanely annoying.. I'm missing something simple and I've
                been all:


                Windows Services is a new name for NT Services in .NET. This tutorial steps you through creating a Windows Service and how to install and start it.


                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]" <willy.denoyett e@telenet.bewro te in message
                news:e790%234DV IHA.5980@TK2MSF TNGP04.phx.gbl. ..
                "Chizl" <Chizl@NoShitMa il.comwrote in message
                news:egTEHx%23U IHA.5596@TK2MSF TNGP05.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.

                Comment

                • Willy Denoyette [MVP]

                  #9
                  Re: Services..

                  "Chizl" <Chizl@NoShitMa il.comwrote in message
                  news:u3k4WlNVIH A.4440@TK2MSFTN GP06.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.




                  Comment

                  • Mr. Arnold

                    #10
                    Re: Services..


                    "Chizl" <Chizl@NoShitMa il.comwrote in message
                    news:OvzhE6NVIH A.5980@TK2MSFTN GP04.phx.gbl...
                    This is getting insanely annoying.. I'm missing something simple and
                    I've been all:


                    Windows Services is a new name for NT Services in .NET. This tutorial steps you through creating a Windows Service and how to install and start it.

                    >
                    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.

                    In this article, we'll see a way to create a simple Windows Service that can be reusable in that it can be used as the basis for any repeated operation that we would like to transform to a Windows Service.In other words, we can create our own assembly


                    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.



                    Comment

                    • Chizl

                      #11
                      Re: Services..


                      "Mr. Arnold" <MR. Arnold@Arnold.c omwrote in message
                      news:uBiWpeQVIH A.4972@TK2MSFTN GP02.phx.gbl...
                      >
                      You can roll your on too.
                      >
                      In this article, we'll see a way to create a simple Windows Service that can be reusable in that it can be used as the basis for any repeated operation that we would like to transform to a Windows Service.In other words, we can create our own assembly

                      >
                      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
                      ProjectInstalle r.cs, the ProjectInstalle r() method is being called, but I'm
                      not doing anything in ProjectInstalle r() 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,P rogram.cs->Main() Called
                      2008-01-12 17:34:32:7656,S ervice1.cs->Service1() Called
                      2008-01-12 17:34:32:7656,P rogram.cs->ServiceBase.Ru n() Calling
                      2008-01-12 17:34:34:2500,P rogram.cs->ServiceBase.Ru n() Returned
                      2008-01-12 17:34:34:2500,P rogram.cs->Main() Leaving

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


                      Comment

                      • Chizl

                        #12
                        Re: Services..

                        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" <Chizl@NoShitMa il.comwrote in message
                        news:ua1cPdXVIH A.5816@TK2MSFTN GP06.phx.gbl...
                        >
                        "Mr. Arnold" <MR. Arnold@Arnold.c omwrote in message
                        news:uBiWpeQVIH A.4972@TK2MSFTN GP02.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
                        ProjectInstalle r.cs, the ProjectInstalle r() method is being called, but
                        I'm not doing anything in ProjectInstalle r() 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,P rogram.cs->Main() Called
                        2008-01-12 17:34:32:7656,S ervice1.cs->Service1() Called
                        2008-01-12 17:34:32:7656,P rogram.cs->ServiceBase.Ru n() Calling
                        2008-01-12 17:34:34:2500,P rogram.cs->ServiceBase.Ru n() Returned
                        2008-01-12 17:34:34:2500,P rogram.cs->Main() Leaving
                        >
                        When I run under a service mode, this is all I get..
                        2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Called
                        2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Leaving
                        >

                        Comment

                        • Chizl

                          #13
                          Re: Services..

                          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.



                          "Chizl" <Chizl@NoShitMa il.comwrote in message
                          news:OPPljkXVIH A.5164@TK2MSFTN GP03.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" <Chizl@NoShitMa il.comwrote in message
                          news:ua1cPdXVIH A.5816@TK2MSFTN GP06.phx.gbl...
                          >>
                          >"Mr. Arnold" <MR. Arnold@Arnold.c omwrote in message
                          >news:uBiWpeQVI HA.4972@TK2MSFT NGP02.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
                          >ProjectInstall er.cs, the ProjectInstalle r() method is being called, but
                          >I'm not doing anything in ProjectInstalle r() 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,P rogram.cs->Main() Called
                          >2008-01-12 17:34:32:7656,S ervice1.cs->Service1() Called
                          >2008-01-12 17:34:32:7656,P rogram.cs->ServiceBase.Ru n() Calling
                          >2008-01-12 17:34:34:2500,P rogram.cs->ServiceBase.Ru n() Returned
                          >2008-01-12 17:34:34:2500,P rogram.cs->Main() Leaving
                          >>
                          >When I run under a service mode, this is all I get..
                          >2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Called
                          >2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Leaving
                          >>
                          >
                          >

                          Comment

                          • Willy Denoyette [MVP]

                            #14
                            Re: Services..

                            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" <Chizl@NoShitMa il.comschreef in bericht
                            news:OPPljkXVIH A.5164@TK2MSFTN GP03.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" <Chizl@NoShitMa il.comwrote in message
                            news:ua1cPdXVIH A.5816@TK2MSFTN GP06.phx.gbl...
                            >>
                            >"Mr. Arnold" <MR. Arnold@Arnold.c omwrote in message
                            >news:uBiWpeQVI HA.4972@TK2MSFT NGP02.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
                            >ProjectInstall er.cs, the ProjectInstalle r() method is being called, but
                            >I'm not doing anything in ProjectInstalle r() 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,P rogram.cs->Main() Called
                            >2008-01-12 17:34:32:7656,S ervice1.cs->Service1() Called
                            >2008-01-12 17:34:32:7656,P rogram.cs->ServiceBase.Ru n() Calling
                            >2008-01-12 17:34:34:2500,P rogram.cs->ServiceBase.Ru n() Returned
                            >2008-01-12 17:34:34:2500,P rogram.cs->Main() Leaving
                            >>
                            >When I run under a service mode, this is all I get..
                            >2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Called
                            >2008-01-12 17:36:12:1093,P rojectInstaller .cs->ProjectInstall er() Leaving
                            >>
                            >
                            >

                            Comment

                            • Mr. Arnold

                              #15
                              Re: Services..


                              "Chizl" <Chizl@NoShitMa il.comwrote in message
                              news:ua1cPdXVIH A.5816@TK2MSFTN GP06.phx.gbl...
                              >
                              "Mr. Arnold" <MR. Arnold@Arnold.c omwrote in message
                              <snipped>
                              Here is what I figured out since my last post.. I found that under
                              ProjectInstalle r.cs, the ProjectInstalle r() method is being called, but
                              I'm
                              I have never used the ProjectInstalle r.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
                              ProjectInstalle r.cs. The Createventlog() is in the Onstart(). :)


                              Comment

                              Working...