Mysterious GDI+ error. What could cause this?

Jon Jacobs 86 Reputation points
2021-06-09T19:29:09.12+00:00

We have many users of the internal application scattered across the country.
One user had been running the application on an Old Win 7 machine, and now he has it installed on his new Win 10 machine.
As soon as he started using the application on the new machine, he started getting errors.
Here is the affected code in the PrintStackHeaderSheets method:

  string outFile = "StackHeaderSheets.tif";
            try
            {
                for (int i = 0; i < sheets; i++)
                {
                    int which = initial + i;
                    string Which = (which).ToString("D4");
                    string SHD = SH + "-" + Which;
                    shformvalues.Heading = SHD;

                    Bitmap bmp = DrawSH();

                    string fn = "File_" + i.ToString("D3") + ".bmp";
                    string FQFN = Path.Combine(DataPath, fn);
                    bmp.Save(FQFN);
                }
                CreateMultiPageTiff(outFile);
            }
            catch (Exception ex)
            {
                string tr = TraceTrim(ex);
                wr(tr);
                MessageBox.Show(tr);
                return;
            }
            string msg = CreateAndLauchBatFileToPrint(outFile, PrinterName);
            istatus.Show("Printing... " + msg);
        }

This section throws an exception (only on the new computer), which is recorded in the application's log file by the wr(tr) call:
19:12:55 Line:109 file:AppLogic.Print.cs Method:Void PrintStackHeaderSheets(System.Object)
A generic error occurred in GDI+.
Line 109 is the bmp.Save(FQFN); statement. This seems an odd place to throw a graphics error. Is this possible? What would cause this?

The computer and the user are about 1000 miles from my location, so I cannot directly troubleshoot.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,586 questions
0 comments No comments
{count} votes

Accepted answer
  1. Song Zhu - MSFT 906 Reputation points
    2021-06-10T08:53:21.643+00:00

    Maybe you can refer to this similar thread: A Generic error occurred in GDI+ in Bitmap.Save method


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.