24 Şubat 2011 Perşembe

error 1053 eventtype clr20r3

In case it's of use to anyone, I was encountering this error when using encrypted sections of the config file for my Windows service. We do this for Web sites all the time, and make sure to grant the IIS worker process access to the RSA key that's used to decrypt the config file. However, when your Windows service is running as LocalService, it can't access that key and decrypt the config file. If you elevate it to run as NetworkService, then it's OK.

http://runtingsproper.blogspot.com/2010/02/solved-error-1053-eventtype-clr20r3.html

using System; using System.Collections.Generic; using System.Linq; using System.ServiceProcess; using System.Text; using System.Diagnostics; namespace SampleWindowsService { static class Program { /// /// The main entry point for the application. /// static void Main() { try { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SampleWindowsService() }; ServiceBase.Run(ServicesToRun); } catch (Exception ex) { string SourceName = "WindowsService.ExceptionLog"; if (!EventLog.SourceExists(SourceName)) { EventLog.CreateEventSource(SourceName, "Application"); } EventLog eventLog = new EventLog(); eventLog.Source = SourceName; string message = string.Format("Exception: {0} \n\nStack: {1}", ex.Message, ex.StackTrace); eventLog.WriteEntry(message, EventLogEntryType.Error); } } } }