Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Windows Service in Windows XP

Windows Service in Windows XP

Scheduled Pinned Locked Moved C#
csharphelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    ksanju1000
    wrote on last edited by
    #1

    Hi, I have made set up for user defined Windows Service and tested with Window2000 It working fine but when i install the windows service in Windows XP, i get error while running the windows service can any one tell me is there an\y difference in making Windows service in Win2k and Win XP I am making WIndows service (User defiend) in c# regards, Sanjeev

    D 1 Reply Last reply
    0
    • K ksanju1000

      Hi, I have made set up for user defined Windows Service and tested with Window2000 It working fine but when i install the windows service in Windows XP, i get error while running the windows service can any one tell me is there an\y difference in making Windows service in Win2k and Win XP I am making WIndows service (User defiend) in c# regards, Sanjeev

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There are differences in what's supported, but it's usually what 2000 doesn't support that XP does. Since you didn't mention what the error was, of what your coding is doing when the error occurs, it's impossible to tell you anything useful. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      K 1 Reply Last reply
      0
      • D Dave Kreskowiak

        There are differences in what's supported, but it's usually what 2000 doesn't support that XP does. Since you didn't mention what the error was, of what your coding is doing when the error occurs, it's impossible to tell you anything useful. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        K Offline
        K Offline
        ksanju1000
        wrote on last edited by
        #3

        hi I have installed dotnetframework in Win XP and Win2k when i run Windows Service and click on desktop of my product its showing me the following error Commn Language Runtime Debugging Services Process id=0xb50(2896),Thread id=0xb54(2900) click OK to terminate the application Click CANCEL to debug the application What should i write in my Windows Services(User defined service) so that it should not show the above error When i run my product exe from the desktop and after that i run my windows services it shows that only one instance of application is allowed at a time This program should identify if any man.exe exist it should stop that instance and start another instance of man.exe but this program as a windows service does not work protected override void OnStart(string[] args) { // TODO: Add code here to start your service. Process[] aProcesses1; if (aProcesses1.Length > 0) { if(rd1==true) { // The last excel process is the orphaned process which is killed aProcesses1[aProcesses1.Length-1].Kill(); rd1=false; } } int intExcelPID; aProcesses1=Process.GetProcessesByName("man"); string strProc="These are the processes running \n"; for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++) { intExcelPID = aProcesses1[i].Id; strProc+=intExcelPID.ToString()+ " "; } //Retrive from registry the value of Path RegistryKey hklm =Registry.LocalMachine; hklm=hklm.OpenSubKey("SOFTWARE\\man"); Object obp=hklm.GetValue("Path"); string file=obp.ToString() + "\\man.exe"; Process.Start(@file); } When i write the above program it does not work even it does not start when i start my computer Regards sanjeev

        D 1 Reply Last reply
        0
        • K ksanju1000

          hi I have installed dotnetframework in Win XP and Win2k when i run Windows Service and click on desktop of my product its showing me the following error Commn Language Runtime Debugging Services Process id=0xb50(2896),Thread id=0xb54(2900) click OK to terminate the application Click CANCEL to debug the application What should i write in my Windows Services(User defined service) so that it should not show the above error When i run my product exe from the desktop and after that i run my windows services it shows that only one instance of application is allowed at a time This program should identify if any man.exe exist it should stop that instance and start another instance of man.exe but this program as a windows service does not work protected override void OnStart(string[] args) { // TODO: Add code here to start your service. Process[] aProcesses1; if (aProcesses1.Length > 0) { if(rd1==true) { // The last excel process is the orphaned process which is killed aProcesses1[aProcesses1.Length-1].Kill(); rd1=false; } } int intExcelPID; aProcesses1=Process.GetProcessesByName("man"); string strProc="These are the processes running \n"; for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++) { intExcelPID = aProcesses1[i].Id; strProc+=intExcelPID.ToString()+ " "; } //Retrive from registry the value of Path RegistryKey hklm =Registry.LocalMachine; hklm=hklm.OpenSubKey("SOFTWARE\\man"); Object obp=hklm.GetValue("Path"); string file=obp.ToString() + "\\man.exe"; Process.Start(@file); } When i write the above program it does not work even it does not start when i start my computer Regards sanjeev

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Wow. Where to begin... First, you've put this in the the OnStart procedure of your service. This means that it will only run ONCE per start of the service or on startup of Windows. OnStart is meant for you to start your service code, possibly on another thread. The way you have it setup, your code will execute once, then stop. The error comes up because you have a problem with your code in the OnStart() method. You've got ALOT of problems with this code.

          protected override void OnStart(string[] args)
          {
          // TODO: Add code here to start your service.

          Process\[\] aProcesses1;
          if (aProcesses1.Length > 0) 
          {
              if(rd1==true)
              {
                  **// The below statement is NOT true!  The last Excel process in NOT
                  // guaranteed to be the orphaned process!  Whatever you mean by this...**
                  // The last excel process is the orphaned process which is killed
          
                  **// Your code here is killing off the second to last process in the
                  // list, WHATEVER this process is, even a System process!  <- BAD!
                  // You're not checking to see if it is Excel!
                  // On top of that, you're not even retrieving the list of processes.
                  // All your doing is creating a process object that doesn't represent
                  // any process and trying to call Kill on it.  THIS WILL FAIL!
                  aProcesses1\[aProcesses1.Length-1\].Kill();
                  rd1=false;
              }
          }
          
          int intExcelPID;
          aProcesses1=Process.GetProcessesByName("man");
          string strProc="These are the processes running \\n";
          for (int i = 0; i <= aProcesses1.GetUpperBound(0); i++)
          {
              intExcelPID = aProcesses1\[i\].Id;
              strProc+=intExcelPID.ToString()+ "  ";
          }    
          
          //Retrive from registry the value of Path
          RegistryKey hklm=Registry.LocalMachine;
          hklm=hklm.OpenSubKey("SOFTWARE\\\\man");
          Object obp=hklm.GetValue("Path");
          string file=obp.ToString() + "\\\\man.exe";
          Process.Start(@file);
          

          }**

          But first, I take it your trying to find Excel processes that are left open by an application? Why? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups