Ejemplo n.º 1
0
 private void UnsafeWriteEventLog(TraceEventType type, EventLogCategory category, System.ServiceModel.Diagnostics.EventLogEventId eventId, string[] logValues, byte[] sidBA, GCHandle stringsRootHandle)
 {
     using (SafeEventLogWriteHandle handle = SafeEventLogWriteHandle.RegisterEventSource(null, this.eventLogSourceName))
     {
         if (handle != null)
         {
             HandleRef strings = new HandleRef(handle, stringsRootHandle.AddrOfPinnedObject());
             System.ServiceModel.Diagnostics.NativeMethods.ReportEvent(handle, (ushort)EventLogEntryTypeFromEventType(type), (ushort)category, (uint)eventId, sidBA, (ushort)logValues.Length, 0, strings, null);
         }
     }
 }
Ejemplo n.º 2
0
        internal static SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName)
        {
            SafeEventLogWriteHandle retval = NativeMethods.RegisterEventSource(uncServerName, sourceName);
            int error = Marshal.GetLastWin32Error();

            if (retval.IsInvalid)
            {
                Debug.Print("SafeEventLogWriteHandle::RegisterEventSource[" + uncServerName + ", " + sourceName + "] Failed. Last Error: " +
                            error.ToString(CultureInfo.InvariantCulture));
            }
            return(retval);
        }