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. Can't run windows service

Can't run windows service

Scheduled Pinned Locked Moved C#
csharpdatabaseasp-netcomgraphics
2 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.
  • S Offline
    S Offline
    saikat_00
    wrote on last edited by
    #1

    Hi, I've problem creating windows service, that can insert values into database using Sql-server 2000 and platform is ASP.NET 2.0 (C#), anyway I followed the whole code using from 'the code project' website; http://www.codeproject.com/cs/system/WindowsService.asp I write the whole code below again, and please let me know, what's wrong... Thanks. // WindowsService.cs using System; using System.Diagnostics; using System.ServiceProcess; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.Configuration; namespace WindowsService { class WindowsService : ServiceBase { /// /// Public Constructor for WindowsService. /// - Put all of your Initialization code here. /// public WindowsService() { this.ServiceName = "My Windows Service"; this.EventLog.Source = "My Windows Service"; this.EventLog.Log = "Application"; // These Flags set whether or not to handle that specific // type of event. Set to true if you need it, false otherwise. this.CanHandlePowerEvent = true; this.CanHandleSessionChangeEvent = true; this.CanPauseAndContinue = true; this.CanShutdown = true; this.CanStop = true; if (!EventLog.SourceExists("My Windows Service")) EventLog.CreateEventSource("My Windows Service", "Application"); } /// /// The Main Thread: This is where your Service is Run. /// static void Main() { ServiceBase.Run(new WindowsService()); Test.ConnectionManager.Instance().Cb_Wap_NewItem(); // I addded this part from my } /// /// Dispose of objects that need it here. /// /// Whether or not disposing is going on. protected override void Dispose(bool disposing) { base.Dispose(disposing); } /// /// OnStart: Put startup code here /// - Start threads, get inital data, etc. /// /// protected override void OnStart(string[] args) {

    W 1 Reply Last reply
    0
    • S saikat_00

      Hi, I've problem creating windows service, that can insert values into database using Sql-server 2000 and platform is ASP.NET 2.0 (C#), anyway I followed the whole code using from 'the code project' website; http://www.codeproject.com/cs/system/WindowsService.asp I write the whole code below again, and please let me know, what's wrong... Thanks. // WindowsService.cs using System; using System.Diagnostics; using System.ServiceProcess; using System.Collections.Generic; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.Configuration; namespace WindowsService { class WindowsService : ServiceBase { /// /// Public Constructor for WindowsService. /// - Put all of your Initialization code here. /// public WindowsService() { this.ServiceName = "My Windows Service"; this.EventLog.Source = "My Windows Service"; this.EventLog.Log = "Application"; // These Flags set whether or not to handle that specific // type of event. Set to true if you need it, false otherwise. this.CanHandlePowerEvent = true; this.CanHandleSessionChangeEvent = true; this.CanPauseAndContinue = true; this.CanShutdown = true; this.CanStop = true; if (!EventLog.SourceExists("My Windows Service")) EventLog.CreateEventSource("My Windows Service", "Application"); } /// /// The Main Thread: This is where your Service is Run. /// static void Main() { ServiceBase.Run(new WindowsService()); Test.ConnectionManager.Instance().Cb_Wap_NewItem(); // I addded this part from my } /// /// Dispose of objects that need it here. /// /// Whether or not disposing is going on. protected override void Dispose(bool disposing) { base.Dispose(disposing); } /// /// OnStart: Put startup code here /// - Start threads, get inital data, etc. /// /// protected override void OnStart(string[] args) {

      W Offline
      W Offline
      Weckmann
      wrote on last edited by
      #2

      My experience with Windows services is that you have to login the service with a user account to use any network operations. So try to change this: //# Service Account Information serviceProcessInstaller.Account = ServiceAccount.LocalSystem; serviceProcessInstaller.Username = null; serviceProcessInstaller.Password = null; into: //# Service Account Information serviceProcessInstaller.Account = ServiceAccount.User; serviceProcessInstaller.Username = yourusername; serviceProcessInstaller.Password = yourpassword; With the correct values of course...

      -------------------- Bertram Weckmann www.svizzer.com --------------------

      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