المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Newbie struggling with ArgumentException



C# Programming
01-16-2010, 01:53 AM
Hi,

As the subject states I'm a complete newbie in programming.
I've coded a little program that uses picture boxes to display images of dices.
After filling the picture boxes with an image a PictureBox[pictureBoxNumber].Image.Dispose() is executed.
All the loops I'm using work fine, but if I press the "Alt" or "Alt Gr" key on the keyboard after the button_Click event has run an ArgumentException gets thrown.
The stack trace doesn't make me any wiser though. I've copied it to be able to post it so here it is:
bij System.Drawing.Image.get_Width()
bij System.Drawing.Image.get_Size()
bij System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSizeMode mode)
bij System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
bij System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
bij System.Windows.Forms.Control.WmPaint(Message& m)
bij System.Windows.Forms.Control.WndProc(Message& m)
bij System.Windows.Forms.Control.ControlNative********OnMessage(Message& m)
bij System.Windows.Forms.Control.ControlNative********WndProc(Message& m)
bij System.Windows.Forms.Native********DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
bij System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bij System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
bij System.Windows.Forms.Application.Run(Form mainForm)
bij prjDices.Program.Main() in E:\Mijn documenten\Visual Studio 2008\Projects\solTeerlingen\prjTeerlingen\Program.cs:regel 18
bij System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
bij System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bij Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bij System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bij System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bij System.Threading.ThreadHelper.ThreadStart()
I've been trying to figure out what happens for quite a while now but to no avail.
I'm really completely stuck on this.
If someone could help me understand what causes the exception I'd be very thankful.
I'm not asking for a solution just help to figure out what in heaven's name is going on.

Thanks in advance,

Jeff