I recently distributed Software to our customer and we got a bad image saving issue in their mass production.
Software receives a barcode and a then a trigger via TwinCat Ads Client, sets the ExposureTime for a dark image, snaps an image, set exposuretime to bright image, snaps another image and saves both using the Save() function of DeviceImage.
This however fails for some reason badly by crashing the whole app. I am not even able to catch an exception, it justs crashs the whole process which is very bad in production here. Only info I have is an error log in the windows event log:
Application: TireDoc.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at Stemmer.Cvb.ImgLib.WriteLossyImageFile(IntPtr, Double, System.String) at Stemmer.Cvb.Image.Save(System.String, Double) at TireDoc.ViewModels.MainViewModel+<>c__DisplayClass74_0.<SnapAndSave>b__1() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.Execute() at System.Threading.Tasks.Task.ExecutionContextCallback(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.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()
The application can work fine for hours, even days, but sometimes it randomly crashs with these error.
I already got that error once yesterday, I instantly modified my software to sporadically catch any exception occured by Save() function, but even that didnt help.
Why can there be a AccessViolationException?