System.Security.SecurityException : 원본을 찾을 수 없지만 일부 또는 모든 이벤트 로그를 검색 할 수 없습니다. 액세스 할 수없는 로그 : 보안
Windows 서비스를 만들려고하는데이 서비스를 설치하려고하면 롤백되어 다음 오류가 발생합니다.
System.Security.SecurityException : 원본을 찾을 수 없지만 일부 또는 모든 이벤트 로그를 검색 할 수 없습니다. 액세스 할 수없는 로그 : 보안.
이것이 무엇을 의미하는지 모르겠습니다. 먼저 테스트를 수행하고 있기 때문에 내 응용 프로그램은 최소한의 것입니다.
내 설치 코드 :
namespace WindowsService1
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
//set the privileges
processInstaller.Account = ServiceAccount.LocalSystem;
processInstaller.Username = null;
processInstaller.Password = null;
serviceInstaller.DisplayName = "My Service";
serviceInstaller.StartType = ServiceStartMode.Manual;
//must be the same as what was set in Program's constructor
serviceInstaller.ServiceName = "My Service";
this.Installers.Add(processInstaller);
this.Installers.Add(serviceInstaller);
}
private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
}
}
내 서비스 코드 :
public partial class Service1 : ServiceBase
{
public Service1()
{
this.ServiceName = "My Service";
}
protected override void OnStart(string[] args)
{
base.OnStart(args);
}
protected override void OnStop()
{
base.OnStop();
}
}
사용자 이름과 암호를 입력하라는 메시지가 표시되면 어딘가에 다음과 같이 설정되어 Account = ServiceAccount.User
있습니다. 이것이 발생할 수있는 유일한 방법입니다. 아마도 위 주석의 코드가 실행되지 않거나 나중에 코드를 실행하여 다시 변경 될 수 있습니다.
As far as your second paragraph, in general, I would think a service would be fine for this if you don't want it to be see on the console or run as a task. I am not sure if I understand the part about running it as ASP.NET and having it not allow you to see the database...
Finally, in your last paragraph, I can't speak to the NullExeception without knowing more about what is going on in your installer's code.
I got the same exception when trying to install a service from the command line when using installutil in Windows 7. The solution was to open the command line as Administrator and then run installutil.
Also you may find it easier to use a framework like TopShelf to host your services, because it manages all the setup configuration from the name and description of the service to how your recovery process will work. It also allows to easily start your service from inside the IDE when you are debugging it.
Run your command prompt as administrator. It will solve your problem
Run as Administrator
This is a very common issue that programmers are missing out
I solve this same issue by opening the VS2013 Developer Console with administrative permissions.
You are probably trying to install a service using
- A user account which does not have sufficient rights OR
- A user with Administrator privileges but did not run the Command Prompt in 'Administrator Mode'.
Specifically, the issue in this case is the creation of some EventLog registry keys during service install.
One way to fix this is to make sure that you are running the Command Prompt in Administrator mode. (Right-click > Run as Administrator)
I have also encountered some cases where this method still fails to solve the SecurityException problem due to some registry keys not having 'Full Control' permissions for Administrator accounts.
The following keys should have 'Full Control' set for Administrators in order for the service to be able to write to the EventLog:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application
This may be done by:
- Invoking the Windows Registry Editor
- Run [Win + R]
- Type 'regedit'
- OK
- Navigate to a path listed above
- Right click on the desired path
- Make sure that both Read and Full Control permission checkboxes are ticked for Administrators
- Click Apply and OK
- Repeat the same process for the other path
I was getting this error(above in the OP) while trying to test for the existence of an EventLog
if (!EventLog.SourceExists("applicatioName"))
EventLog.CreateEventSource("applicatioName", "Application");
Running VisualStudio as Administrator resolved the issue.
'programing tip' 카테고리의 다른 글
플롯을 PDF로 저장 (0) | 2020.11.06 |
---|---|
Google지도 Places API V3 자동 완성-입력시 첫 번째 옵션 선택 (0) | 2020.11.06 |
산업 표준에서 #define이 금지되어 있습니까? (0) | 2020.11.06 |
SearchView를 자동으로 확장하고 포커스를 제공합니다. (0) | 2020.11.06 |
Pandas의 열 이름을 기반으로 여러 열 삭제 (0) | 2020.11.06 |