COMPlusExceptionCode -532462766 when calling EventLog.WriteEntry

  • Thread starter Thread starter Lachlann562
  • Start date Start date
L

Lachlann562

Guest
Ive been struggling with a problem where my service was crashing with an unhandled exception, i eventually tracked it down as an issue when trying to log an exception. originally i was logging asynchornously however even when i switched to synchronous logging i couldnt catch the problem. through a bit of luck i tracked it down to the method where im writing to the eventlog.


It appears that my call to EventLog.WriteEntry is crashing with the COMPlusExceptionCode -532462766


The following section of code is the method that performs the actual write to the eventlog, this same method works 99.99% of the time, the only way i caught this was a "catch everything" block and putting a breakpoint before it returns.


public void LogEvent(int LogLevel, string Message, Exception Ex, ErrorType LogType, string Source, int EventID, DateTime EventTime)
{
try
{
if (LogLevel <= this.LogLevel)
{
EventLogEntryType etype = EventLogEntryType.Information;

switch (LogType)
{
case ErrorType.Error: etype = EventLogEntryType.Error; break;
case ErrorType.Warning: etype = EventLogEntryType.Warning; break;
}

if (AppName == null)
{
AppName = System.Reflection.Assembly.GetExecutingAssembly().FullName;
}

EVLog.WriteEntry((AppName.Length == 0 ? "Application " : AppName) + " has identified an event to log. \r\n" +
" Occured: " + EventTime.ToString() + "\r\n" + // UTC
(Source == null ? "" : " Source: " + Source + "\r\n") +
" LogLevel: " + LogLevel.ToString() + "\r\n" +
(Message == null ? "" : " Message: " + Message + "\r\n") +
(Ex == null ? "" : " --------------------------------\r\n" +
" Stack Trace: " + Ex.ToString())
, etype, EventID);
}
}
// if unable to log dont crash
catch (Exception)
{
return;
};
}


As you can see ive checked to ensure none of my data elements are null and yet it keeps crashing. It appears to occur only when my higher level code encounters a deadlock however both threads have try/catch blocks that call this logging class.


Here is an example eventlog entry that is written when it crashes:

Log Name: Application
Source: .NET Runtime
Date: 7/8/2013 8:55:11 PM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: L00704.corp.dsg.local
Description:
Application: XMLScheduler2_Service.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
Stack:
at System.Diagnostics.EventLogInternal.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32, Int16, Byte[])
at System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32)
at Utilities.Logging.EVLogger.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32, System.DateTime)
at Utilities.Logging.EVLogger.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32)
at Utilities.Logging.AsynchLogging.LogEvent(Int32, Int32, System.String, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32, System.DateTime)
at Utilities.Logging.AsynchLogging.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, Int32)
at XMLScheduler2_Service.Service.Worker.OrgWorker.ProcessOrgQueue()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()

Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0 1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2013-07-09T00:55:11.000000000Z" />
<EventRecordID>349037</EventRecordID>
<Channel>Application</Channel>
<Computer>L00704.corp.dsg.local</Computer>
<Security />
</System>
<EventData>
<Data>Application: XMLScheduler2_Service.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
Stack:
at System.Diagnostics.EventLogInternal.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32, Int16, Byte[])
at System.Diagnostics.EventLog.WriteEntry(System.String, System.Diagnostics.EventLogEntryType, Int32)
at Utilities.Logging.EVLogger.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32, System.DateTime)
at Utilities.Logging.EVLogger.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32)
at Utilities.Logging.AsynchLogging.LogEvent(Int32, Int32, System.String, System.String, System.Exception, Utilities.Logging.ErrorType, System.String, Int32, System.DateTime)
at Utilities.Logging.AsynchLogging.LogEvent(Int32, System.String, System.Exception, Utilities.Logging.ErrorType, Int32)
at XMLScheduler2_Service.Service.Worker.OrgWorker.ProcessOrgQueue()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
</Data>
</EventData>
</Event>


which is shortly followed by:


Log Name: Application
Source: Application Error
Date: 7/8/2013 8:55:12 PM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: L00704.corp.dsg.local
Description:
Faulting application name: XMLScheduler2_Service.exe, version: 1.0.0.0, time stamp: 0x51db5f19
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83c8a
Exception code: 0xe0434352
Fault offset: 0x0000c41f
Faulting process id: 0x2998
Faulting application start time: 0x01ce7c3ec6663b39
Faulting application path: C:\Users\jmarshall\Documents\Visual Studio 2010\Projects\XMLScheduler2_Service\XMLScheduler2_Service\bin\Debug\XMLScheduler2_Service.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 3531e879-e832-11e2-92e8-a8986a53a0af
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0 1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2013-07-09T00:55:12.000000000Z" />
<EventRecordID>349040</EventRecordID>
<Channel>Application</Channel>
<Computer>L00704.corp.dsg.local</Computer>
<Security />
</System>
<EventData>
<Data>XMLScheduler2_Service.exe</Data>
<Data>1.0.0.0</Data>
<Data>51db5f19</Data>
<Data>KERNELBASE.dll</Data>
<Data>6.1.7601.18015</Data>
<Data>50b83c8a</Data>
<Data>e0434352</Data>
<Data>0000c41f</Data>
<Data>2998</Data>
<Data>01ce7c3ec6663b39</Data>
<Data>C:\Users\jmarshall\Documents\Visual Studio 2010\Projects\XMLScheduler2_Service\XMLScheduler2_Service\bin\Debug\XMLScheduler2_Service.exe</Data>
<Data>C:\Windows\syswow64\KERNELBASE.dll</Data>
<Data>3531e879-e832-11e2-92e8-a8986a53a0af</Data>
</EventData>
</Event>


Any help would be greatly appreciated!


Here is the original exception i was trying to log (in this instance):

System.Data.StrongTypingException: The value for column BranchName in table XSEventProvider is DBNull. ---> System.InvalidCastException: Unable to cast object of type System.DBNull to type System.String.
at XMLScheduler2_Service.Service.XSDataSet.XSEventProviderRow.get_BranchName() in C:\Users\jmarshall\Documents\Visual Studio 2010\Projects\XMLScheduler2_Service\XMLScheduler2_Service\XSDataSet.Designer.cs:line 2721
--- End of inner exception stack trace ---
at XMLScheduler2_Service.Service.XSDataSet.XSEventProviderRow.get_BranchName() in C:\Users\jmarshall\Documents\Visual Studio 2010\Projects\XMLScheduler2_Service\XMLScheduler2_Service\XSDataSet.Designer.cs:line 2724
at XMLScheduler2_Service.Service.Worker.OrgWorker.ProcessOrgQueue() in C:\Users\jmarshall\Documents\Visual Studio 2010\Projects\XMLScheduler2_Service\XMLScheduler2_Service\OrgWorker.cs:line 217

Continue reading...
 
Back
Top