System.ArgumentOutOfRangeException was unhandled

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Ernesto Obregon
Avatar
I have the following Exception that happens at random times when I launch my SyntaxEditor application that is not caught in any of my Try Catch Finally statements during my FormLoadEvent. I have had this for quite a while but it was completely random so I did not pay too much attention to it until now. Here is my stack trace can you please see if you can help me with this.

System.ArgumentOutOfRangeException was unhandled
  Message="Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.Collections.ArrayList.get_Item(Int32 index)
       at ActiproSoftware.SyntaxEditor.TokenCollection.get_Item(Int32 index)
       at ActiproSoftware.SyntaxEditor.EditorView.a(PaintEventArgs A_0, Rectangle A_1, DocumentLine A_2, DisplayLine A_3, EditPositionRange A_4, Int32& A_5)
       at ActiproSoftware.SyntaxEditor.EditorView.OnRender(PaintEventArgs e)
       at ActiproSoftware.WinUICore.UIElement.Render(PaintEventArgs e)
       at ActiproSoftware.WinUICore.UIControl.OnRenderChildElements(PaintEventArgs e)
       at ActiproSoftware.WinUICore.UIControl.Render(PaintEventArgs e)
       at ActiproSoftware.WinUICore.UIControl.a(PaintEventArgs A_0)
       at ActiproSoftware.WinUICore.UIControl.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 ActiproSoftware.SyntaxEditor.SyntaxEditor.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.IMsoComponentManager.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 MyEditor.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.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

Thanks
Ernesto

[Modified at 10/31/2007 10:44 AM]

Comments (2)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Can you make a small sample project that shows it happening and email that over? I'm not sure that we can figure this one out without being able to debug it. Your best bet is to take the Form that this happens on, move that to the new repro project, remove all your proprietary code and just leave the SyntaxEditor portion.


Actipro Software Support

Posted 16 years ago by Ernesto Obregon
Avatar
Excellent Idea! I did as you suggested and was able to find the error(s) I had in my code. Doing so produced a stacktrace with better info to track down the cause. There were a couple of errors I found that I did not know were even there, however the error in question stemmed from a BackGroundWorker.RunWorkerAsync() method that performed a Document.LoadFromXML(LanguagePath,0) however because I did NOT include an Application.DoEvents() method after the asynchronous worker thread call to keep the UI messages moving, at random times I received the exception.

Thanks, problem solved
Ernesto
The latest build of this product (v24.1.0) was released 25 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.