c# - Visual Studio 2008 Warning About Changes to Designer-Generated Code -
This question is kind of arbitrary but still interesting to me; I was thinking that Visual Studio 2008 constant :
public class Service101: ServiceBase // & lt; Comment & gt; /// shown at start - & gt; Settings - & gt; Control panel - & gt; Administrative Tools - & gt; Service /// & lt; / Remark & gt; Internal constant string SERVICE_NAME = "WinSvc101"; /// & lt; Comment & gt; /// shown at start - & gt; Settings - & gt; Control panel - & gt; Administrative Tools - & gt; Service /// & lt; / Remark & gt; Internal cast string DISPLAY_NAME = "Windows Service 101"; /// & lt; Summary & gt; /// Public consultator for service /// & lt; / Summary & gt; Public Service101 () {InitializeComponent (); } Private Zero initial group () {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, "Applications"); }} #Arison Incidents /// & lt; Summary & gt; /// Settlement of objects which require it /// & lt; / Summary & gt; /// & lt; Param name = "disposing" & gt; Whether the display is running or not. & Lt; / Param & gt; Protected Override Zero Dispos (Bool Displant) {// TODO: Add Cleanup Code Here (if necessary) Base. Disposal; }
Showing the following warning at design time:
Warning 1 can not process code on designer line 68 : If (EventLog.SourceExists (DISPLAY_NAME)) {EventLog.CreateEventSource (DISPLAY_NAME, "app"); } The code is generated by the code designer within the 'InitializeComponent' and should not be manually modified. Please remove any changes and try to open the designer again. E: \ Proyectos \ beanstalk \ dotnetfx \ trunk \ WinSvc101 \ WinSvc101 \ Service101.cs 69 0
Any comments would be greatly appreciated. Thanks in advance.
When you add the code to InitializeComponent (), the designer is not happy
. Try doing something instead:
Public Service101 () {InitializeComponent (); This.createEventSource (); } Private Zero start initializeComponent () {this.ServiceName = SERVICE_NAME; This.EventLog.Source = DISPLAY_NAME; This.EventLog.log = "application"; } Incidents of making zero () (if! EventLog.SourceExists (DISPLAY_NAME)) {EventLog.CreateEventSource (DISPLAY_NAME, "app");}}
Comments
Post a Comment