AccessViolation Crashes application

Dec 1, 2011 at 2:39 PM

Ok here is a fun one for everyone....

  I have created my application that calls about 2200 different sites to "check in" with them on a daily basis.  This application should run as a windows service (so no one needs to be logged in for it to work).  The problem I am running into is that when I am running as a windows service I recieve an AccessViolation within ITapi (actually in ATL COM to be more specific) at a random point during the execution of the dialout operation. The stack trace says its happening in a method that is ultimately called by CreateCall within ITapi3,  I have a try catch around my call to CreateCall but that is never hit and the service just stops....  The funny thing is when I run the same library executed by a Windows Application triggered by a button press I get no errors and everything works spectacularly.

here is the Event log entry...

Log Name:      Application
Source:        .NET Runtime
Date:          11/30/2011 9:58:52 PM
Event ID:      1026
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      DILFK-EAG-DEV2.global.spx.com
Description:
Application: EaglePolloutWindowsService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at <Module>.ATL.CComPtrBase<JulMar::Tapi3::Native::ITCallInfo>.{dtor}(ATL.CComPtrBase<JulMar::Tapi3::Native::ITCallInfo>*)
   at JulMar.Tapi3.Internal.TapiBase.CastToInterface<JulMar::Tapi3::Native::ITCallInfo,1>(ATL.CComPtr<JulMar::Tapi3::Native::ITCallInfo>*)
   at JulMar.Tapi3.TCall.GetCallInfoItf(ATL.CComPtr<JulMar::Tapi3::Native::ITCallInfo>*)
   at JulMar.Tapi3.TCall.get_CallState()
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.<WaitForComplete>b__46(EaglePhoneLibrary.Entities.ConnectionEntity)
   at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].RemoveAll(System.Predicate`1<System.__Canon>)
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.WaitForComplete()
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.<WaitForIterationToComplete>b__3c()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.runTryCode(System.Object)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

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="2011-12-01T03:58:52.000Z" />
    <EventRecordID>10350</EventRecordID>
    <Channel>Application</Channel>
    <Computer>DILFK-EAG-DEV2.global.spx.com</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: EaglePolloutWindowsService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at &lt;Module&gt;.ATL.CComPtrBase&lt;JulMar::Tapi3::Native::ITCallInfo&gt;.{dtor}(ATL.CComPtrBase&lt;JulMar::Tapi3::Native::ITCallInfo&gt;*)
   at JulMar.Tapi3.Internal.TapiBase.CastToInterface&lt;JulMar::Tapi3::Native::ITCallInfo,1&gt;(ATL.CComPtr&lt;JulMar::Tapi3::Native::ITCallInfo&gt;*)
   at JulMar.Tapi3.TCall.GetCallInfoItf(ATL.CComPtr&lt;JulMar::Tapi3::Native::ITCallInfo&gt;*)
   at JulMar.Tapi3.TCall.get_CallState()
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.&lt;WaitForComplete&gt;b__46(EaglePhoneLibrary.Entities.ConnectionEntity)
   at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].RemoveAll(System.Predicate`1&lt;System.__Canon&gt;)
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.WaitForComplete()
   at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.&lt;WaitForIterationToComplete&gt;b__3c()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.runTryCode(System.Object)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
</Data>
  </EventData>
</Event>

In Summary....

I get this entry in the event log when I run the application as a Windows Service  the stack trace is not always the same (many times it is in the CreateCall method chain there are several Try/Catch statements that should catch this in order to continue gracefully but they don't get executed (including those in the ITapi3 library.  This does NOT happen when running as a windows application.

 

any help is greatly appreciated...

Dec 7, 2011 at 3:51 PM

got another type of exception...

This time I was running as a user account that was created to run the service (has Domain Users group oermissions only).

 

Application: EaglePolloutWindowsService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.FormatException
Stack:
   at System.Text.StringBuilder.AppendFormat(System.IFormatProvider, System.String, System.Object[])
   at System.String.Format(System.IFormatProvider, System.String, System.Object[])
   at System.String.Format(System.String, System.Object[])
   at JulMar.Tapi3.TapiException.TraceOut(System.Diagnostics.TraceEventType, System.String, System.Object[])
   at JulMar.Tapi3.TTapi.ThreadedProcessTapiMessage(System.Object)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()