Erro serviço 1053
Boa tarde Pessoal. estou com problemas para iniciar um serviço construído em C#. Pesquisei aqui no fórum e tentei de acordo com os comentários mas não funcionou, por isso resolvi postar aqui para pedir ajuda..
Fiz um exemplo bem básico para isolar mesmo o erro mas mesmo assim não funcionou..
segue meu código
Ainda assim criei o arquivo c:\teste\Teste.txt para ver se eram problemas de privilégio mas não rolou.. alguém sabe o que pode ser??
valeu
Fiz um exemplo bem básico para isolar mesmo o erro mas mesmo assim não funcionou..
segue meu código
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Timers; namespace WindowsServiceTeste { public partial class ServiceTeste : ServiceBase { private System.Timers.Timer timerMobile; public ServiceTeste() { InitializeComponent(); } protected override void OnStart(string[] args) { try { StreamWriter vWriter = new StreamWriter(@"c:\teste\Teste.txt", true); vWriter.Flush(); vWriter.Close(); Thread t = new Thread(new ThreadStart(this.InitTimer)); t.Start(); } catch (Exception e) { StreamWriter vWriter = new StreamWriter(@"c:\teste\Teste.txt", true); vWriter.WriteLine(e.ToString()); vWriter.Flush(); vWriter.Close(); } } protected override void OnStop() { timerMobile.Enabled = false; } private void InitTimer() { timerMobile = new System.Timers.Timer(); //wire up the timer event timerMobile.Elapsed += new ElapsedEventHandler(timer_Elapsed); //set timer interval //var timeInSeconds = Convert.ToInt32(ConfigurationManager.AppSettings["TimerIntervalInSeconds"]); double timeInSeconds = 3.0; timerMobile.Interval = (timeInSeconds * 1000); // timer.Interval is in milliseconds, so times above by 1000 timerMobile.Enabled = true; } protected void timer_Elapsed(object sender, ElapsedEventArgs e) { int timer_fired = 0; } } }
Ainda assim criei o arquivo c:\teste\Teste.txt para ver se eram problemas de privilégio mas não rolou.. alguém sabe o que pode ser??
valeu
Eric Miranda
Curtidas 0