While creating a project using Windows Service VS2013 project template i noticed that after add an EventLog component from the tools box the #region named "Component Designer generated code" is filled with the following code:
private void InitializeComponent()
{
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
//
// Service1
//
this.ServiceName = "Service1";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
}
My question is: Should add the Designer generate a line like:
components.Add(this.eventLog1);
after the line
this.eventLog1 = new System.Diagnostics.EventLog();
? The fact that exist a method like:
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
and that System.Diagnostics.EventLog implement the IDisposable interface make me think that such line should be included in Designer the generated code. I know that is not a big deal and that just in very rare cases (e.g. you play dirty with ServicesBase derived instances in the Main method) the lack of that line could impact the performance of the app, but still not have sense to me have a Disposal method implementation like that and not add a line like: components.Add(this.eventLog1);. Any thoughts?