Click here to Skip to main content
15,902,299 members
Home / Discussions / C#
   

C#

 
GeneralRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Jim_Snyder27-Oct-17 4:28
professionalJim_Snyder27-Oct-17 4:28 
GeneralRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Richard MacCutchan27-Oct-17 5:05
mveRichard MacCutchan27-Oct-17 5:05 
AnswerRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Richard Deeming27-Oct-17 1:15
mveRichard Deeming27-Oct-17 1:15 
GeneralRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Nathan Minier27-Oct-17 1:28
professionalNathan Minier27-Oct-17 1:28 
AnswerRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Jim_Snyder27-Oct-17 4:24
professionalJim_Snyder27-Oct-17 4:24 
AnswerRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Gerry Schmitz27-Oct-17 4:43
mveGerry Schmitz27-Oct-17 4:43 
GeneralRe: Exporting result to .csv format instead of .xlsx without using interop.excel Pin
Richard MacCutchan27-Oct-17 5:06
mveRichard MacCutchan27-Oct-17 5:06 
QuestionProgram crashes when form is refreshed Pin
Member 1274878324-Oct-17 11:55
Member 1274878324-Oct-17 11:55 
I have a Windows forms program that crashes every time I turn off the monitor, minimize the form, or perform an update on the form. I seem to be able to Update() individual objects on the form without any issue, but repainting the entire form causes the following error:

Quote:
System.ArgumentException was unhandled
HResult=-2147024809
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Image.get_RawFormat()
at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32 width, Int32 height)
at System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
InnerException:



As you can see, none of the trace refers to my code, but to System.Drawing dll. Here is the code I used to attempt to isolate the problem and produce this message:

 try
                {
                    if (WindowState != FormWindowState.Minimized)
                        this.Invalidate(true);
                }
                catch (System.ArgumentException ax)
                {
                    World.Debugging.RTMessage("FindNextCritter()", "System.ArgumentException", "Exception: " + ax);
                }
                catch (Exception ex)
                {
                    World.Debugging.RTMessage("FindNextCritter()", "this.Invalidate()", "Exception: " + ex);
                }

                try
                {
                    if (WindowState != FormWindowState.Minimized)
                        this.Update();
                }
                catch (System.ArgumentException ax)
                {
                    World.Debugging.RTMessage("FindNextCritter()", "System.ArgumentException", "Exception: " + ax);
                }
                catch (Exception ex)
                {
                    World.Debugging.RTMessage("FindNextCritter()", "this.Update()", "Exception: " + ex);
                }
... more stuff
}


The debugger pointed to the line that says "this.Update()", but neither of the two catch blocks on the associated Try managed to catch the exception. Remember, I also get the same result when I turn off the monitor or drag the form off the screen, but then the unhandled exception points to my Application.DoEvents() statement, which is also wrapped in a try block that fails to catch the exception. The rather wordy test code above is an attempt to isolate the issue.

I am using Microsoft Visual C# 2010 Express; you know, the free SDK downloaded from Microsoft. I suspect that I have done something stupid to the form, but I don't think I can upload that to show it. It contains 8 bitmap images that the program successfully updates from bitmap objects built internally, one doughnut graph defined on the form, two buttons, four radio buttons in a groupbox, several labels and textboxes, a checkbox, and another groupbox enclosing two of the bitmaps, the doughnut graph, and a label. Some of the labels have \n in them and stretch across multiple lines.

Yes, I know this is a big form. It's currently running on a TV screen with a form size of 1831,977. It was just more convenient and informative to have everything up there at once.

Thanks in advance for your help. I have googled around and found people with similar issues, but with no relevant solution. I am not an experience C# coder (old school CICS/COBOL here!) and I do not have local peers to ask.
AnswerRe: Program crashes when form is refreshed Pin
Dave Kreskowiak24-Oct-17 12:08
mveDave Kreskowiak24-Oct-17 12:08 
GeneralRe: Program crashes when form is refreshed Pin
Member 1274878324-Oct-17 16:20
Member 1274878324-Oct-17 16:20 
AnswerRe: Program crashes when form is refreshed Pin
Eddy Vluggen24-Oct-17 13:33
professionalEddy Vluggen24-Oct-17 13:33 
GeneralRe: Program crashes when form is refreshed Pin
Member 1274878324-Oct-17 16:10
Member 1274878324-Oct-17 16:10 
QuestionRe: Program crashes when form is refreshed Pin
Eddy Vluggen25-Oct-17 5:09
professionalEddy Vluggen25-Oct-17 5:09 
AnswerRe: Program crashes when form is refreshed Pin
OriginalGriff24-Oct-17 20:20
mveOriginalGriff24-Oct-17 20:20 
PraiseRe: Program crashes when form is refreshed Pin
Member 1274878331-Oct-17 15:43
Member 1274878331-Oct-17 15:43 
GeneralRe: Program crashes when form is refreshed Pin
OriginalGriff31-Oct-17 20:58
mveOriginalGriff31-Oct-17 20:58 
GeneralRe: Program crashes when form is refreshed Pin
Member 127487831-Nov-17 10:38
Member 127487831-Nov-17 10:38 
QuestionIssue with WPF C# Treeview GetFiles Pin
Member 1348136124-Oct-17 8:08
Member 1348136124-Oct-17 8:08 
SuggestionRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming24-Oct-17 9:49
mveRichard Deeming24-Oct-17 9:49 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136124-Oct-17 10:01
Member 1348136124-Oct-17 10:01 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming25-Oct-17 1:50
mveRichard Deeming25-Oct-17 1:50 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136125-Oct-17 3:09
Member 1348136125-Oct-17 3:09 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming25-Oct-17 3:31
mveRichard Deeming25-Oct-17 3:31 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Member 1348136125-Oct-17 9:21
Member 1348136125-Oct-17 9:21 
GeneralRe: Issue with WPF C# Treeview GetFiles Pin
Richard Deeming26-Oct-17 1:26
mveRichard Deeming26-Oct-17 1:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.