이 질문은 일종의 일화이지만 여전히 흥미 롭습니다. 이 디자인 타임에 다음과 같은 경고을 보여주는 것으로Visual Studio 2008 디자이너 생성 코드의 변경 내용에 대한 경고
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);
}
:
이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
모든 의견은 매우 감사하겠습니다 내가 왜 비주얼 스튜디오 2008 상수 다음 사용을 사랑하지 않습니다 궁금 해서요 . 많이 미리 감사드립니다.
Andrew, 댓글에 대해 많은 감사를드립니다! 변경 사항이 적용되면 메시지는 다음으로 변경됩니다. 경고 \t 1 변수 'SERVICE_NAME'이 (가) 신고되지 않았거나 할당되지 않았습니다. 경고 \t 2 변수 'DISPLAY_NAME'이 (가) 신고되지 않았거나 할당되지 않았습니다. –
경고를 해결하기 위해 Service101.SERVICE_NAME과 Service101.DISPLAY_NAME을 각각 사용해야했습니다. –