nccgroup / ncccodenavi

NCC Code Navigator
GNU Affero General Public License v3.0
54 stars 10 forks source link

ArgumentOutOfRangeException - files without any extensions #48

Open irsdl opened 10 years ago

irsdl commented 10 years ago

It gives the following error when I double click on files that have no extension:

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

\ Exception Text ** System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. Parameter name: startIndex at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at Win.CodeNavi.frmCodeViewNew.frmCodeViewNew_Load(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.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.18444 built by: FX451RTMGDR

CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

Win.CodeNavi Assembly Version: 1.2.0.0 Win32 Version: 1.2.0.0

CodeBase: file:///C:/CodeNavi/Win.CodeNavi.exe

System.Windows.Forms Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

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.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Xml Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

System.Core Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Configuration Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

Microsoft.GeneratedCode Assembly Version: 1.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

System.Xml.Linq Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.18408 built by: FX451RTMGREL

CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll

ScintillaNET Assembly Version: 2.5.2.0 Win32 Version: 2.5.2.0

CodeBase: file:///C:/CodeNavi/ScintillaNET.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:

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.

ShariqueS commented 8 years ago

This error occur because code is trying to figure out file extension. but because there is no file extension Path.GetExtension(strFilePath) will return null and then code is trying to .substring(1) on a null string which is throwing this error. Affected code: https://github.com/nccgroup/ncccodenavi/blob/master/Win.CodeNavi/Win.CodeNavi/frmCodeViewNew.cs#L212 Console.WriteLine(frmMain.AssemblyDirectory + "\\NCCCodeNavi.CodeHighlighting\\" + Path.GetExtension(strFilePath).Substring(1) + ".xml");

I will fix it and raise a pull request over weekend.

ShariqueS commented 8 years ago

hi @irsdl, Fix is merged in main branch. this error should be resolved now.