Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# app exits without exception when deleting a temp file

I have a class in a C# program (.Net 4.61) that uses Word and the Amyuni PDF suite to build a formatted PDF file. During the process, four temporary PDF files are created in the user's temp folder:

private string TempFolder = Path.GetTempPath();

When the process completes, I have the following cleanup method that runs to delete any temp files generated during the process:

private void EraseTempFiles()
{
    // For each temp file:
    foreach (string tempFile in TempFiles)
    {
        if (File.Exists(tempFile))
        {
            File.Delete(tempFile);
        }
    }
}

This works file on nearly all of the deployed Windows systems (all 64-bit Windows 7 systems), however on a few of them, when the EraseTempFiles method deletes the third of the temporary files, the application immediately exits. No exceptions are thrown (I've surrounded the File.Delete in a try-catch to determine this).

The files can be deleted using Windows Explorer no problem.

I've tried saving all temp files in a different folder and changing how they are named with no change in behavior. Running ProcDump to track the application has not caught anything, it simply reports:

[23:54:52] The process has exited.
[23:54:52] Dump count not reached.

I've also subscribed to the unhandled exception event:

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler);

private void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
  System.Windows.Forms.MessageBox.Show(((Exception)e.ExceptionObject).Message);
  throw new NotImplementedException();
}

That handler is also never called.

I've never seen a program exit like this with no explanation. It seems that Windows itself might be killing the process due to some violation, but I can't tell what since all of the temp files are basically the same and it is able to delete the first two with no problem.

Anyone seen this type of behavior before?

like image 420
twitort Avatar asked Nov 30 '17 18:11

twitort


1 Answers

After disabling Trend Micro, the program no longer exits when deleting the temp files. Re-enable Trend Micro, and sure enough, it gets killed. Now need to determine how to allow Trend Micro to run, but not kill my application!

like image 194
twitort Avatar answered Nov 14 '22 22:11

twitort