简体   繁体   English

该进程由于未处理的异常而终止-WCF服务

[英]The process was terminated due to an unhandled exception - WCF service

So I have a WCF service that i created that gets messages from customer and parses them to desired output and sends them to other customer via TCP/HTTP/FTP etc. This windows service has long running threads for each customer created using TPL's. 因此,我创建了一个WCF服务,该服务从客户那里获取消息,并将其解析为所需的输出,然后通过TCP / HTTP / FTP等将其发送给其他客户。该Windows服务为使用TPL创建的每个客户都具有长期运行的线程。

So for logging I have used NLOG, log to file and event viewer with below configurations 因此,对于日志记录,我使用了NLOG,使用以下配置记录到文件和事件查看器

<target xsi:type="File" name="flatfile" layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=tostring,StackTrace}" 
              archiveAboveSize="2000000" archiveFileName="${basedir}/logs/archive/${shortdate}-{#####}.engine.log" archiveNumbering="Sequence" archiveEvery="None" 
              maxArchiveFiles="100" fileName="${basedir}/logs/engine.current.log" keepFileOpen="true" concurrentWrites="true" />

<target xsi:type="EventLog" name="eventlog" layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=tostring} ${StackTrace}" log="Application" source="Nuance Interface Engine Service" eventId="${event-properties:EventID}" />

Even when I added concurrentWrites="true", when I start WCF service after 20+ hours of time passes I got below error in event viewer 即使我添加了巧写“ Writes =“ true”,但经过20多个小时后启动WCF服务时,事件查看器中的错误也仍然存在

    Application: MyWcfService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.OutOfMemoryException
   at System.Text.StringBuilder..ctor(System.String, Int32, Int32, Int32)
   at NLog.Layouts.SimpleLayout.GetFormattedMessage(NLog.LogEventInfo)
   at NLog.Targets.FileTarget.GetFormattedMessage(NLog.LogEventInfo)
   at NLog.Targets.FileTarget.GetBytesToWrite(NLog.LogEventInfo)
   at NLog.Targets.FileTarget.Write(NLog.Common.AsyncLogEventInfo[])
   at NLog.Targets.Target.WriteAsyncLogEvents(NLog.Common.AsyncLogEventInfo[])
   at NLog.Targets.Wrappers.AsyncTargetWrapper.ProcessPendingEvents(System.Object)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireQueuedTimerCompletion(System.Object)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Could you please someone guide me on where this issue is occuring, I thought multiple threads are accessing this log file hence I added concurrentWrites="true" attribute to nlog's file target. 您能不能请某人指导我发生此问题的位置,我以为有多个线程正在访问此日志文件,因此我向nlog的文件目标添加了并发写入= true。

after 1 second passes to above error, I see one more error in my event viewer. 经过1秒以上的错误后,我在事件查看器中又看到一个错误。

Faulting application name: Hl7ic.Engine.View.exe, version: 18.0.1.160, time stamp: 0x5af5cd1f
Faulting module name: KERNELBASE.dll, version: 6.3.9600.18938, time stamp: 0x5a7dd8a7
Exception code: 0xe0434352
Fault offset: 0x00015ef8
Faulting process id: 0x1074
Faulting application start time: 0x01d3ea7338d9851c
Faulting application path: C:\Program Files (x86)\MyServices\MyWcfService.exe
Faulting module path: C:\windows\SYSTEM32\KERNELBASE.dll
Report Id: 59b36929-5688-11e8-80ca-005056a80aaa
Faulting package full name: 
Faulting package-relative application ID:

OutOfMemoryException means that there is not enough memory on the machine. OutOfMemoryException表示机器上没有足够的内存。 Maybe it has been used up by another application. 也许它已经被另一个应用程序用完了。 Maybe it has been used up by your application. 也许它已被您的应用程序用尽。 Maybe your 32 bit application have used up its memory address space of 2 Gigabyte. 也许您的32位应用程序用完了2 GB的内存地址空间。

To diagnose this error, then use Process Explorer to capture a Fulldump of the application that uses too much memory. 要诊断此错误,请使用Process Explorer捕获占用过多内存的应用程序的Fulldump。 Then try using Visual Studio or WinDbg to investigate the memory dumpfile. 然后尝试使用Visual Studio或WinDbg调查内存转储文件。

To remove NLog from the radar, then you can upgrade to NLog 4.4.6 (or newer). 要从雷达中删除NLog,则可以升级到NLog 4.4.6(或更高版本)。 It will reduce memory allocations with 70 pct. 它将减少与70 pct的内存分配。 from older versions (When using FileTarget) 从旧版本开始(使用FileTarget时)

If running NLog 4.4.6 (or newer) then you can optimize NLog even further by not using <targets async="true"> but instead use this default-wrapper : 如果运行NLog 4.4.6(或更高版本),则可以通过不使用<targets async="true">来进一步优化NLog,而可以使用以下default-wrapper

<targets>
   <default-wrapper xsi:type="AsyncWrapper" timeToSleepBetweenBatches="0" />

   <target .... />

   <target .... />

</targets>

See also https://github.com/NLog/NLog/wiki/Performance 另请参阅https://github.com/NLog/NLog/wiki/Performance

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 进程由于未处理的异常而终止-Windows Service - The process was terminated due to an unhandled exception - Windows Service 由于未处理的异常,进程被终止 - The process was terminated due to an unhandled exception DataGridView错误:由于未处理的异常,进程已终止 - DataGridView error : The process was terminated due to an unhandled exception c#console app error(由于未处理的异常导致进程终止) - c# console app error (The process was terminated due to an unhandled exception) 由于InteropServices.SEHException中出现未处理的异常,该进程已终止 - The process was terminated due to an unhandled exception in InteropServices.SEHException 由于未处理的异常,该进程被终止。 ews 中的 System.Net.HttpWebRequest.GetResponse() 异常 - The process was terminated due to an unhandled exception. System.Net.HttpWebRequest.GetResponse() exception in ews 未处理的异常会使WCF服务崩溃吗? - unhandled exception will make WCF service crash? 由于StackOverflowException,进程终止 - Process is terminated due to StackOverflowException WCF异常:未处理InvalidOperationException - WCF Exception: InvalidOperationException was unhandled 进程由于堆栈溢出而终止 - Process Terminated due to stack overflow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM