The source was not found, but some or all event logs could not be searched

前端 未结 10 2227
栀梦
栀梦 2020-12-01 02:12

I am getting the following exception. I have given full control to Asp.net account on Eventlogs in Registry edit.

[SecurityException: The source was not

10条回答
  •  生来不讨喜
    2020-12-01 03:13

    If you just want to sniff if a Source exists on the local machine but don't have ability to get authorization to do this, you can finger it through the following example (VB).

    This bypasses the security error. You could similarly modify this function to return the LogName for the Source.

    Public Shared Function eventLogSourceExists(sSource as String) as Boolean
        Try
            EventLog.LogNameFromSourceName(sSource, ".")
            Return True
        Catch
            Return False
        End Try
    End Function
    

提交回复
热议问题