Index outside the bounds of the array exception with plugin

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Index outside the bounds of the array exception with plugin

Post by wjstarck » Mon Apr 08, 2013 9:21 am

I've gotten this several times right clicking to complete appointments from the ApptBook and this one was right clicking in the chart to complete a procedure. Version 13.1.18.

Now that I look at the error I see it's related to one of my plugin methods I was recently working on. This was where I was getting the error because you guys had changed the FormProcEdit textBox to a RichTextBox.

viewtopic.php?f=3&t=4952

What does the error mean?

Thanks,

Code: Select all

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Anesthesia.FormOpenDentalA.UpperLowerNoteFixFromMenu(Object sender, Procedure procCur, Procedure procOld, ODtextBox textNotes)
   at Anesthesia.Plugin.HookAddCode(Object sender, String hookName, Object[] parameters)
   at OpenDentBusiness.Plugins.HookAddCode(Object sender, String hookName, Object[] parameters)
   at OpenDental.ContrChart.menuItemSetComplete_Click(Object sender, EventArgs e)
   at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.MenuItem.MenuItemData.Execute()
   at System.Windows.Forms.Command.Invoke()
   at System.Windows.Forms.Command.DispatchID(Int32 id)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.UserControl.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18034 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
OpenDental
    Assembly Version: 13.1.18.0
    Win32 Version: 13.1.18.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/OpenDental.exe
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18034 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18036 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18021 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
CodeBase
    Assembly Version: 7.1.0.0
    Win32 Version: 7.1.0.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/CodeBase.DLL
----------------------------------------
OpenDentBusiness
    Assembly Version: 13.1.18.0
    Win32 Version: 13.1.18.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/OpenDentBusiness.DLL
----------------------------------------
NHunspell
    Assembly Version: 0.9.6.0
    Win32 Version: 0.9.6.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/NHunspell.DLL
----------------------------------------
SparksToothChart
    Assembly Version: 4.7.1.0
    Win32 Version: 4.7.1.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/SparksToothChart.DLL
----------------------------------------
Microsoft.DirectX.Direct3D
    Assembly Version: 1.0.2902.0
    Win32 Version: 9.05.132.0000
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX.Direct3D/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.Direct3D.dll
----------------------------------------
xImageDeviceManager
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/xImageDeviceManager.DLL
----------------------------------------
SigPlusNET
    Assembly Version: 1.1.4050.24928
    Win32 Version: 
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/SigPlusNET.DLL
----------------------------------------
msvcm90
    Assembly Version: 9.0.30729.6161
    Win32 Version: 9.00.30729.6161
    CodeBase: file:///C:/Windows/WinSxS/x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57/msvcm90.dll
----------------------------------------
System.Web.Services
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Services/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18034 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
OpenDental.XmlSerializers
    Assembly Version: 13.1.18.0
    Win32 Version: 13.1.18.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/OpenDental.XmlSerializers.DLL
----------------------------------------
AxInterop.AcroPDFLib
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/AxInterop.AcroPDFLib.DLL
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.18034 built by: FX45RTMGDR
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
CDT
    Assembly Version: 12.4.30.0
    Win32 Version: 12.4.30.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/CDT.DLL
----------------------------------------
MySql.Data
    Assembly Version: 6.2.4.0
    Win32 Version: 6.2.4.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/MySql.Data.DLL
----------------------------------------
System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
Oracle.DataAccess
    Assembly Version: 2.112.2.0
    Win32 Version: 2.112.2.0
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/Oracle.DataAccess.DLL
----------------------------------------
System.EnterpriseServices
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.0.30319.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
Ionic.Zip
    Assembly Version: 1.9.1.4
    Win32 Version: 1.9.1.4
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/Ionic.Zip.DLL
----------------------------------------
Anesthesia13.1
    Assembly Version: 13.1.4845.35573
    Win32 Version: 13.1.4845.35573
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/Anesthesia.dll
----------------------------------------
TimeOut12.2
    Assembly Version: 12.2.4534.18892
    Win32 Version: 12.2.4534.18892
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/TimeOut.dll
----------------------------------------
Microsoft.DirectX
    Assembly Version: 1.0.2902.0
    Win32 Version: 5.04.00.2904
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX/1.0.2902.0__31bf3856ad364e35/Microsoft.DirectX.dll
----------------------------------------
Microsoft.DirectX.Direct3DX
    Assembly Version: 1.0.2911.0
    Win32 Version: 9.12.589.0000
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.DirectX.Direct3DX/1.0.2911.0__31bf3856ad364e35/Microsoft.DirectX.Direct3DX.dll
----------------------------------------
Microsoft.VisualC
    Assembly Version: 10.0.0.0
    Win32 Version: 11.00.50709.17929 built by: FX45RTMREL
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualC/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualC.dll
----------------------------------------
AutomaticUpdater
    Assembly Version: 2.6.18.4
    Win32 Version: 2.6.18.4
    CodeBase: file:///C:/Program%20Files%20(x86)/Open%20Dental/AutomaticUpdater13.1.dll
----------------------------------------
SkinSoft.VisualStyler
    Assembly Version: 1.0.0.0
    Win32 Version: 2.3.3.7
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/SkinSoft.VisualStyler/1.0.0.0__0fda9f423e1d9830/SkinSoft.VisualStyler.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Index outside the bounds of the array exception with plu

Post by wjstarck » Mon Apr 08, 2013 9:35 am

FYI, with a little more research I won't get the exception if there is any text in the box. This only happens when the default note for a proc is initially being saved to the textBox.

Here is that whole method again if that helps.

Code: Select all

      public static void UpperLowerNoteFixFromMenu(object sender, Procedure procCur, Procedure procOld, ODtextBox textNotes) { //setting 'Complete' from ContrAppr or FormProcEdit uses this method

            string test = textNotes.Text;
            Procedure procOrig = procOld;
            if (procOld.Note == String.Empty || procCur.Note == String.Empty || procOld.Note == null) {
                procCur.Note = ProcCodeNotes.GetNote(procCur.ProvNum, procCur.CodeNum);
                beforeDelim = procCur.Note;
                afterDelim = procCur.Note;

				/*      string[] parts = beforeDelim.Split(new string[] { "\r\n+-+\r\n" }, StringSplitOptions.None);
					   for (int j = 0; j < parts.Length; j++) {
						   if (j == 0) {
							   beforeDelim = (parts[j]);
							   string test = beforeDelim;
						   }
						   if (j == 1) {
							   afterDelim = (parts[j]);
						   }
					   }	 
				 */
				//This is the old way. Either way works if both \r are removed as of OD version 13.1.16. 
				//NOTE 04/04/2013: Above quit working because these boxes got changed to rich text boxes by OD as per jsalmon, so the \r is no longer necessary	-wjs


				//We'll use the following now because it's a little cleaner	anyways

				string[] delim = new string[] { "\n+-+\n" };
				string[] result;
				result = beforeDelim.Split(delim, StringSplitOptions.None);
				beforeDelim = result[0];
				afterDelim = result[1];
					
                if (procCur.ToothNum == String.Empty) {
                    Procedures.Update(procCur, procOld);
                    textNotes.Text = procOrig.Note;
                    return;
                }
            }
            else if (procOld.Note == null) {
                beforeDelim = procCur.Note;
                afterDelim = procCur.Note;
            }
            else {
                beforeDelim = procOld.Note;
                afterDelim = procOld.Note;
			}
            string upperNote = beforeDelim;
            string lowerNote = afterDelim;
            Regex isPedoUpper = new Regex("^[a-jA-J]*$");
            Regex isPedoLower = new Regex("^[k-tK-T]*$");
            if (procCur.ToothNum != "") { //because some Proc don't have a toothNum, eg., exams

                if (isPedoUpper.IsMatch(procCur.ToothNum)) { //primary upper teeth
                    if (procCur.Note != procOld.Note)
                        procCur.Note = upperNote;
                    if (procCur.Note != "")  {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (isPedoLower.IsMatch(procCur.ToothNum)) { //primary lower teeth
                    if (procCur.Note != procOld.Note)
                        procCur.Note = lowerNote;
                    if (procCur.Note != "")  {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (Convert.ToInt64(procCur.ToothNum) <= 16 || ((Convert.ToInt64(procCur.ToothNum) >= 51 && (Convert.ToInt64(procCur.ToothNum) <= 66)))) { //check if permanent or supernumerary upper
                    if (procCur.Note != procOld.Note)
                        procCur.Note = upperNote;
                    if (procCur.Note != "") {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

                else if (Convert.ToInt64(procCur.ToothNum) >= 17 | ((Convert.ToInt64(procCur.ToothNum) >= 67 && (Convert.ToInt64(procCur.ToothNum) <= 82)))) { //check if permanent or supernumerary lower
                    if (procCur.Note != procOld.Note)
                        procCur.Note = lowerNote;
                    if (procCur.Note != "") {//prevents double note getting added from ContrChart
                        procOld.Note = String.Empty;
                    }
                }

            }
            else if (procCur.Note != "") {
                procCur.Note = procOld.Note; //prevents template note from overwriting changes to note

            }

            Procedures.Update(procCur, procOld);
            textNotes.Text = procCur.Note; //only needed when completing note on FormProcEdit

        }
Thanks,
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Index outside the bounds of the array exception with plu

Post by wjstarck » Mon Apr 08, 2013 9:43 am

OK, well NVM it's bombing here because there's no delimiter in an exam proc textNote, which was the proc what I was trying to complete when I got the exception.

Code: Select all

afterDelim = result[1];
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

Post Reply