Results 1 to 9 of 9

Thread: [3.0/LINQ] Weird ArgumentException

Threaded View

  1. #1

    Thread Starter
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    [3.0/LINQ] Weird ArgumentException

    I'm getting an unusual ArgumentException and I don't know how to fix it.

    Message: Parameter is not valid.
    Source: "System.Drawing"
    TargetSite: {Int32 get_Width()}
    StackTrace: at System.Drawing.Image.get_Width()
    at System.Drawing.Image.get_Size()
    at Telerik.WinControls.Paint.RadGdiGraphics.DrawBitmap(Image image, Int32 x, Int32 y, Double opacity)
    at Telerik.WinControls.Paint.RadGdiGraphics.DrawBitmap(Image image, Int32 x, Int32 y)
    at Telerik.WinControls.Primitives.ReflectionPrimitive.PaintElement(IGraphics graphics, Single angle, SizeF scale)
    at Telerik.WinControls.RadElement.PaintElement(Graphics rawGraphics, IGraphics graphics, Single angle, SizeF scale, Region currentClip)
    at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintOverride(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.VisualElement.PaintChildren(IGraphics graphics, Rectangle clipRectange, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadElement.Paint(IGraphics graphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RadItem.PaintOverride(IGraphics screenRadGraphics, Rectangle clipRectangle, Single angle, SizeF scale, Boolean useRelativeTransformation)
    at Telerik.WinControls.RootRadElement.Paint(IGraphics graphics, Rectangle clipRectangle)
    at Telerik.WinControls.RadControl.OnPaint(PaintEventArgs e)
    at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
    at System.Windows.Forms.Control.WmPaint(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at Telerik.WinControls.RadControl.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)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    at System.Windows.Forms.Application.Run(ApplicationContext context)
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    at TrailBlazer.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()

    The familiar exception window appears when executing the code, however no line is highlighted.

    The code which is executing at the time of the exception is the following:
    Code:
            private void radCarousel1_ItemDataBound(object sender, ItemDataBoundEventArgs e)
            {
                RadButtonElement button = (RadButtonElement)e.DataBoundItem;
                string str = (string)e.DataItem;
                int tmp = str.LastIndexOf('\\') + 1;
                button.Tag = str;
                button.Text = str.Substring(tmp, str.Length - tmp);
                //button.AutoSize = false;
                button.DisplayStyle = DisplayStyle.Image;
                //button.TextAlignment = ContentAlignment.BottomCenter;
            }
    
            private void radCarousel1_SelectedIndexChanged(object sender, EventArgs e)
            {
                int visibleItemCount = Math.Min(this.radCarousel1.VisibleItemCount, this.radCarousel1.Items.Count);
                int centerOffset = visibleItemCount / 2;
                int itemIndex;
                int selectedIndex = this.radCarousel1.SelectedIndex;
                RadItemCollection carouselItems = this.radCarousel1.Items;
    
                if (selectedIndex >= 0)
                {
                    //Debug.Write("Loading items: ");
                    for (int i = selectedIndex - centerOffset;
                        i - (selectedIndex - centerOffset) < visibleItemCount;
                        i++)
                    {
                        itemIndex = GetActualItemIndex(i);
    
                        RadButtonElement button = (RadButtonElement)carouselItems[itemIndex];
                        if (button.Image == null && !string.IsNullOrEmpty(button.Text))
                        {
                            Image res = Image.FromFile((string)button.Tag);
                            //int tmp = (int)(129d * ((double)res.Height / res.Width));
                           button.Image = res.GetThumbnailImage(129, (int)(129d * ((double)res.Height / res.Width)), this.GetThumbnailImageAbort, IntPtr.Zero);
    
                            imagesLoaded++;
                            //Debug.Write(itemIndex + ", ");
                        }
                    }
    
                    //Debug.WriteLine("");
                }
    
                if (previousSelectedIndex >= 0)
                {
                    //Debug.Write("Unloading images: ");
                    for (int i = previousSelectedIndex - centerOffset;
                        i - (previousSelectedIndex - centerOffset) < visibleItemCount;
                        i++)
                    {
                        itemIndex = GetActualItemIndex(i);
    
                        int firstVisibleItemIndex = GetActualItemIndex(selectedIndex - centerOffset);
    
                        if (firstVisibleItemIndex + visibleItemCount < carouselItems.Count)
                        {
                            if (itemIndex >= firstVisibleItemIndex &&
                                itemIndex < firstVisibleItemIndex + visibleItemCount)
                                continue;
                        }
                        else
                        {
                            if (itemIndex >= firstVisibleItemIndex ||
                                itemIndex < GetActualItemIndex(firstVisibleItemIndex + visibleItemCount))
                                continue;
                        }
    
                        RadButtonElement button = (RadButtonElement)carouselItems[itemIndex];
                        if (button.Image != null)
                        {
                            button.Image = null;
                            imagesLoaded--;
    
                            //Debug.Write(itemIndex + ", ");
                        }
                    }
                    //Debug.WriteLine("");
                }
    
                previousSelectedIndex = selectedIndex;
    
                //Debug.WriteLine(imagesLoaded);
            }
    Since the line in red is the only place where System.Drawing is involved, I am inclined to believe that the Telerik WinForms package I'm using is the source of the exception, however I was unable to determine the exact cause. The weird thing is that the same code in Telerik's own example works fine - see attachment. Can anyone please help?
    Attached Files Attached Files
    Last edited by obi1kenobi; Jan 1st, 2009 at 03:53 PM. Reason: Added attachment
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width