I will try to make this as short and sweet as I possibly can.
I have created an application that is used by my company to call about 2000 different phone numbers each day (used to contact very old devices we have deployed around the US), When I run the application as a Windows Application (written using C# and JulMar ITAPI3 wrapper) the application seems to run rock solid with no issues which tells me at least my code is mostly right....
The problem I am encountering is when I run the same code as a Windows Service (create new project and simply call into the phone dialing library like the windows app does) The service will run for some period of time (varies each time) and then will finally crash. I look at the event log and see that it is an AccessViolation (0xc0000005) in the application. I have a try catch around my call into the tapi wrapper where the exception is happening but the catch never gets hit, I am assuming that it just crashes the app before it can get back to that point.
So in a nutshell, Tapi application works great when run as Windows Application but when run as a Windows Service (running under local system) eventually fails with AccessViolation error that is not caught by the try catch around the "offending" function call.
Any thoughts?
This is running on Windows Server 2008 if that helps any.
EDIT 1: I have tried running this service as several different types of user accounts including local user account, domain account, local system. All of them error out. I have posted a snippet from the event log for one of the failures below.
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<IUnknown>.{dtor}(ATL.CComPtrBase<IUnknown>*)
at JulMar.Tapi3.Internal.TapiBase.Compare(IUnknown*)
at JulMar.Tapi3.TTapi.FindInterface[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](IUnknown*)
at JulMar.Tapi3.TCall.CreateCallAppearance(JulMar.Tapi3.TAddress, IUnknown*)
at JulMar.Tapi3.TAddress.CreateCall(System.String, JulMar.Tapi3.LINEADDRESSTYPES, JulMar.Tapi3.TAPIMEDIATYPES)
at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.CreateNewCall(EaglePhoneLibrary.Entities.ConnectionEntity)
at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.CallTower(EaglePhoneLibrary.Entities.ConnectionEntity)
at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.ContinueIteration()
at EaglePhoneLibrary.Logic.Outgoing.EaglePollout.ContinuePollout(EaglePhoneLibrary.Entities.ConnectionEntity)
at EaglePhoneLibrary.Logic.Outgoing.EaglePollout+<>c__DisplayClass52.<CallTower>b__4e(System.Threading.Tasks.Task)
at System.Threading.Tasks.Task+<>c__DisplayClassb.<ContinueWith>b__a(System.Object)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
at System.Threading.Tasks.Task.ExecutionContextCallback(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()
Thanks to everyone for their help so far and in the future.
Edit 2: I have given up trying to resolve this issue. My best guess is that it stems from an issue with how JulMar is handling some of the COM objects being created in the wrapper. I convinced my company to pay for a license for TraySoft AddTapi .NET and it is working just fine now....
Thanks everyone.