debugger crashes and just points to Application.Run(new Form1()); where is my error
Hello when i run the program it crashes at Application.Run(new Form1()); with this error
Quote:
System.ArgumentOutOfRangeException was unhandled
Message="Index and length must refer to a location within the string.\r\nParameter name: length"
Source="mscorlib"
ParamName="length"
StackTrace:
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at JinxDebug.comm.loadNextRXPacket() in E:\SeniorProj\HighLevel\JinxDebug\JinxDebug\comm.cs:line 132
at JinxDebug.Form1.TimerEventProcessor(Object myObject, EventArgs myEventArgs) in E:\SeniorProj\HighLevel\JinxDebug\JinxDebug\Form1.cs:line 50
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.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 JinxDebug.Program.Main() in E:\SeniorProj\HighLevel\JinxDebug\JinxDebug\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
how can i know where my error is... it looks like a string error but which one ?
oh nevermind it says it "\comm.cs:line 132"
... always when i ask the question just by writing it up I find the answer ... :(
oh well i asked the question midas well do something in it ... this is the function at error
Code:
public string loadNextRXPacket()
{
// get index of next '11'
int i = -1;// rxBuffer.IndexOf(Dw.RXHeader);
// if we found the packet and the buffer contains a whole packet
if (i != -1)// && rxBuffer.Length >= (i+Dw.RX_PacketSZ))
{ // stuff from that index till rxPacketSZ into current packet
currentRXPacket = rxBuffer.Substring(i, Dw.RX_PacketSZ);
rxBuffer = rxBuffer.Remove(i, Dw.RX_PacketSZ); // erase packet from buffer
}else { return null; }
return currentRXPacket;
//return null;
}
edit :::
well i found that a lot of my problems were coming from the code not being rebuilt correctly. I was clicking the play button thinking the code was being rebuilt and it was not. When I clicked build->rebuild my changes took effect. I was really confused because the function that was causing the error was not even being called anywhere.