C# 在exe模式下,获取长度不能小于零参数名称长度
更新:这是代码C# 在exe模式下,获取长度不能小于零参数名称长度,c#,winforms,C#,Winforms,更新:这是代码 string path = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("bin")); 例外文本: Length cannot be less than zero Parameter name : length See the end of this message for details on invoking just-in-time (JIT) debugging
string path = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("bin"));
例外文本:
Length cannot be less than zero
Parameter name : length
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at Negits_POS.frmItemEdit..ctor(String Strmode, String StrItemId)
at Negits_POS.frmItemDetails.btnEdit_Click(Object sender, EventArgs e)
at Negits_POS.frmItemDetails.dgItem_CellMouseDoubleClick_1(Object sender, DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnCellMouseDoubleClick(DataGridViewCellMouseEventArgs e)
at System.Windows.Forms.DataGridView.OnMouseDoubleClick(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.DataGridView.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.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Negits_POS
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_POS.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
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.1 built by: RTMRel
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.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Negits_DAL
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_DAL.DLL
----------------------------------------
Negits_LIB
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_LIB.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version`enter code here`n: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
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.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
MySql.Data
Assembly Version: 6.8.3.0
Win32 Version: 6.8.3.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/MySql.Data/v4.0_6.8.3.0__c5687fc88969c44d/MySql.Data.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Management`enter code here`
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
System.Numerics
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
RabbitMQ.Client
Assembly Version: 3.2.3.0
Win32 Version: 3.2.3.0
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/RabbitMQ.Client/3.2.3.0__89e7d7c5feba84ce/RabbitMQ.Client.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.
长度不能小于零
参数名称:长度
有关调用的详细信息,请参阅此消息的结尾
即时(JIT)调试,而不是此对话框。
**************例外文本**************
System.ArgumentOutOfRangeException:长度不能小于零。
参数名称:长度
在System.String.InternalSubStringWithChecks处(Int32 startIndex、Int32 length、布尔值)
at System.String.Substring(Int32 startIndex,Int32 length)
在Negits_位置frmItemEdit..ctor(字符串Strmode,字符串StrItemId)
在Negits_POS.frmItemDetails.btnEdit_单击(对象发送者,事件参数e)
在Negits_POS.frmItemDetails.dgItem_CellMouseDoubleClick_1(对象发送方,DataGridViewCellMouseevenTargets e)
在System.Windows.Forms.DataGridView.OnCellMouseDoubleClick(DataGridViewCellMouseEventArgs e)中
在System.Windows.Forms.DataGridView.OnMouseDoubleClick(MouseEventArgs e)上
在System.Windows.Forms.Control.WmMouseUp(Message&m、MouseButtons按钮、Int32单击)
位于System.Windows.Forms.Control.WndProc(Message&m)
位于System.Windows.Forms.DataGridView.WndProc(Message&m)
在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)中
在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&m)中
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd、Int32 msg、IntPtr wparam、IntPtr lparam)中
**************加载的程序集**************
mscorlib
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Negits_POS
程序集版本:1.0.0.0
Win32版本:1.0.0.0
代码库:file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_POS.exe
----------------------------------------
System.Windows.Forms
程序集版本:4.0.0.0
Win32版本:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
系统图
程序集版本:4.0.0.0
Win32版本:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
系统
程序集版本:4.0.0.0
Win32版本:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
内吉斯·奥达尔
程序集版本:1.0.0.0
Win32版本:1.0.0.0
代码库:file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_DAL.DLL
----------------------------------------
Negits_LIB
程序集版本:1.0.0.0
Win32版本:1.0.0.0
代码库:file:///C:/Program%20Files%20(x86)/Microsoft/PS/Negits_LIB.DLL
----------------------------------------
系统配置
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
命名空间
程序集版本:4.0.0.0
Win32版本`在此处输入代码`n:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
系统数据
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
系统核心
程序集版本:4.0.0.0
Win32版本:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
MySql.Data
组件版本:6.8.3.0
Win32版本:6.8.3.0
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/MySql.Data/v4.0_6.8.3.0__c5687fc88969c44d/MySql.Data.dll
----------------------------------------
系统.交易
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
系统企业服务
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Management`在此处输入代码`
程序集版本:4.0.0.0
Win32版本:4.0.30319.1(RTMRel.030319-0100)
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
数字系统
程序集版本:4.0.0.0
Win32版本:4.0.30319.1生成者:RTMRel
代码库:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
RabbitMQ.Client
程序集版本:3.2.3.0
Win32版本:3.2.3.0
代码库:file:///C:/Windows/assembly/GAC_MSIL/RabbitMQ.Client/3.2.3.0__89e7d7c5feba84ce/RabbitMQ.Client.dll
----------------------------------------
**************JIT调试**************
要启用即时(JIT)调试,请为
应用程序或计算机(machine.config)必须具有
在system.windows.forms节中设置的值。
应用程序
string path;
if(Application.StartupPath.LastIndexOf("bin") >0)
string path = Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("bin"));
else
{
string path = string.Empty
MessageBox("Check your path : " + Application.StartupPath);
}