This question is kind of anecdotical but still interesting to me; I was wondering why Visual Studio 2008 is not loving the following use of constants:
public class Service101 : ServiceBase
{
/// <remarks>
/// Shown at Start -> Settings -> Control Panel -> Administrative Tools -> Services
/// </remarks>
internal const string SERVICE_NAME = "WinSvc101";
/// <remarks>
/// Shown at Start -> Settings -> Control Panel -> Administrative Tools -> Services
/// </remarks>
internal const string DISPLAY_NAME = "Windows Service 101";
/// <summary>
/// Public constructor for Service101.
/// </summary>
public Service101()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.ServiceName = Service101.SERVICE_NAME;
this.EventLog.Source = Service101.DISPLAY_NAME;
this.EventLog.Log = "Application";
if (!EventLog.SourceExists(Service101.DISPLAY_NAME))
{
EventLog.CreateEventSource(Service101.DISPLAY_NAME, "Application");
}
}
#region Events
/// <summary>
/// Dispose of objects that need it here.
/// </summary>
/// <param name="disposing">Whether or not disposing is going on.</param>
protected override void Dispose(bool disposing)
{
// TODO: Add cleanup code here (if required)
base.Dispose(disposing);
}
As it's showing the following Warning at design time:
Warning 1 The designer cannot process the code at line 68:
if (!EventLog.SourceExists(DISPLAY_NAME))
{
EventLog.CreateEventSource(DISPLAY_NAME, "Application");
}
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. E:\Proyectos\beanstalk\dotnetfx\trunk\WinSvc101\WinSvc101\Service101.cs 69 0
Any comment would be quite appreciated. Thanks much in advance.