Problem when trying to use EventLog.SourceExists method in .NET

后端 未结 4 1963
旧时难觅i
旧时难觅i 2021-01-03 21:31

I am trying to use eventlogs in my application using C#, so I added the following code

if (!EventLog.SourceExists(\"SomeName\"))
EventLog.CreateEventSource(\         


        
4条回答
  •  被撕碎了的回忆
    2021-01-03 22:19

    Good afternoon, The simplest is that you run vs2019 as an administrator, so when debugging or excute the service, it will run correctly without generating the exception.

提交回复
热议问题