반응형

PRB: ASP.NET 응용 프로그램이 이벤트 로그에 새로운 EventSource를 쓰려고 하면 "요청한 레지스트리에 액세스할 수 없습니다" 오류 메시지 발생
 
 
현상
ASP.NET을 사용하여 이벤트 로그에 새로운 이벤트 원본을 만들려고 하면 다음 오류 메시지가 나타날 수 있습니다.
System.Security.SecurityException: 요청한 레지스트리에 액세스할 수 없습니다.
 
 
원인
기본적으로 ASP.NET 작업자 프로세스의 사용자 토큰은 ASPNET(또는 인터넷 정보 서비스[IIS] 6.0에서 실행되는 응용 프로그램의 경우 NetworkService)입니다. "현상" 절의 문제는 사용자 계정이 이벤트 원본을 만들기 위한 올바른 사용자 권한을 갖고 있지 않기 때문에 발생합니다.
 
 
해결 방법
경고: 레지스트리 편집기를 잘못 사용하면 심각한 문제가 발생할 수 있으며 문제를 해결하기 위해 운영 체제를 다시 설치해야 할 수도 있습니다. Microsoft는 레지스트리 편집기를 잘못 사용함으로써 발생하는 문제에 대해 해결을 보증하지 않습니다. 레지스트리 편집기의 사용에 따른 모든 책임은 사용자에게 있습니다. 이 문제를 해결하려면 관리자 권한이 있는 사용자가 ASP.NET 웹 응용 프로그램을 실행하기 전에 이벤트 원본을 만들어야 합니다. 이벤트 원본을 만들려면 다음 방법 중 하나를 사용하십시오.

첫 번째 방법
레지스트리 편집기의 Application 이벤트 로그 아래에 이벤트 원본을 만듭니다. 이렇게 하려면 다음과 같이 수행하십시오. 1. 시작을 누르고 실행을 누릅니다.
2. 열기 입력란에 regedit를 입력합니다.
3. 다음 레지스트리 하위 키를 찾습니다.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application
4. Application 하위 키를 마우스 오른쪽 단추로 누른 다음 새로 만들기를 가리킨 다음 키를 누릅니다.
5. 키 이름으로 TEST를 입력합니다.
6. 레지스트리 편집기를 닫습니다.
 
두 번째 방법
System.Diagnostics 네임스페이스의 EventLogInstaller 클래스를 사용하면 응용 프로그램이 실행되는 동안 읽거나 쓰는 이벤트 로그를 설치하고 구성할 수 있습니다. EventLogInstaller를 사용하여 이벤트 원본을 만들 수 있습니다. 이렇게 하려면 다음과 같이 수행하십시오. 1. Microsoft Visual Basic .NET 또는 Microsoft Visual C# .NET을 사용하여 EventLogSourceInstaller라는 새로운 클래스 라이브러리를 만듭니다. 기본적으로 Class1.vb 파일이나 Class1.cs 파일이 만들어집니다.
2. 솔루션 탐색기에서 EventLogSourceInstaller를 마우스 오른쪽 단추로 누른 다음 참조 추가를 누릅니다.
3. 참조 추가 대화 상자에서 System.Configuration.Install.dll을 두 번 누른 다음 확인을 누릅니다.
4. Class1.vb\Class1.cs를 MyEventLogInstaller.vb\MyEventLogInstaller.cs로 이름을 바꿉니다.
5. MyEventLogInstaller.vb 또는 MyEventLogInstaller.cs의 기존 코드를 다음 예제 코드로 바꿉니다.
Visual Basic .NET 예제Imports System.Diagnostics
Imports System.Configuration.Install
Imports System.ComponentModel
<RunInstaller(True)> _
Public Class MyEventLogInstaller
    Inherits Installer
    Private myEventLogInstaller As EventLogInstaller
    Public Sub New()
        ' Create an instance of 'EventLogInstaller'.
        myEventLogInstaller = New EventLogInstaller()
        ' Set the 'Source' of the event log, to be created.
        myEventLogInstaller.Source = "TEST"
        ' Set the 'Log' that the source is created in.
        myEventLogInstaller.Log = "Application"
        ' Add myEventLogInstaller to 'InstallerCollection'.
        Installers.Add(myEventLogInstaller)
    End Sub
End Class
Visual C# .NET 예제using System;
using System.Diagnostics;
using System.ComponentModel;
using System.Configuration.Install;

namespace EventLogSourceInstaller
{
 [RunInstaller(true)]
 public class MyEventLogInstaller : Installer
 {
  private EventLogInstaller myEventLogInstaller;
  public MyEventLogInstaller()
  {
   //Create Instance of EventLogInstaller
   myEventLogInstaller = new EventLogInstaller();
   // Set the Source of Event Log, to be created.
   myEventLogInstaller.Source = "TEST";
   // Set the Log that source is created in
   myEventLogInstaller.Log = "Application";
      // Add myEventLogInstaller to the Installers Collection.
   Installers.Add(myEventLogInstaller);
  }
 }
}

6. 빌드 메뉴에서 솔루션 빌드를 눌러 EventLogSourceInstaller.dll을 만듭니다.
7. Visual Studio .NET 명령 프롬프트를 엽니다.
8. 명령 프롬프트에서 EventLogSourceInstaller.dll이 있는 폴더로 변경합니다.
9. 다음 명령을 실행하여 아래 EventSource를 만듭니다.
InstallUtil EventLogSourceInstaller.dll
 

참조
자세한 내용을 보려면 다음 Microsoft 웹 사이트를 방문하십시오.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkWalkthroughCreatingEventLogInstallers.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkWalkthroughCreatingEventLogInstallers.asp)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticseventlogclasstopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticseventlogclasstopic.asp)
반응형

+ Recent posts