我有一个非常奇怪的“错误”,我不知道它可能是什么。应用程序是使用 .net 4 框架使用 VS2010 制作的。除了普通程序集,它还使用 MS 互操作 for excel。我在客户端计算机上安装了 Office 2010。
基本上,应用程序解析 excel 表并制作另一个(新文件)结果。问题:当我将 exe 文件复制到桌面(或 PC 上的任何其他位置)时,它会抛出异常,但是当它在存档 (RAR) 中并且存档在桌面上时,它可以正常工作。
我无法安装它,因为他们的系统(电话公司)非常严格,根本不应该使用该应用程序。(工人手动解析,一般需要3个小时,而程序5秒,所以老板不知道,因为他认为他们都很努力:))。
该问题在公司内的其他机器上仍然存在,因此不是孤立的情况。
任何有关它的信息都会受到赞赏。PS如果需要更多信息,请大声疾呼。这是未处理异常的“详细信息”。
有关调用即时 (JIT) 调试而不是此对话框的详细信息,请参阅此消息的末尾。
************** 异常文本 ************** System.ArgumentOutOfRangeException:索引和长度必须引用字符串中的位置。参数名称:System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) at System.String.Substring(Int32 startIndex, Int32 length) at ExcelSvjetlana.Form1.buttonObradi_Click(Object sender, EventArgs e) at System.Windows 的长度.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs 事件) 在 System.Windows.Forms.Control.WmMouseUp(Message& m,MouseButtons 按钮,Int32 点击)在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ButtonBase.WndProc(Message&
************** Loaded Assemblies ************** mscorlib Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300) CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll ---------------------------------------- ExcelSvjetlana Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/Users/sobradovic/Desktop/Interno.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.276 built by: RTMGDR 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.258 built by: RTMGDR CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.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 ---------------------------------------- System.Xml 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.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.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 ---------------------------------------- Microsoft.Office.Interop.Excel Assembly Version: 14.0.0.0 Win32 Version: 14.0.4756.1000 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Excel/14.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll ---------------------------------------- office Assembly Version: 14.0.0.0 Win32 Version: 14.0.4760.1000 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/office/14.0.0.0__71e9bce111e9429c/office.dll ---------------------------------------- Microsoft.CSharp Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.CSharp/v4.0_4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll ---------------------------------------- System.Dynamic Assembly Version: 4.0.0.0 Win32 Version: 4.0.30319.1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Dynamic/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Dynamic.dll ---------------------------------------- Anonymously Hosted DynamicMethods Assembly Assembly Version: 0.0.0.0 Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300) CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.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.
这是你要求的代码。请注意,我确实更改了一些字符串。
private void buttonObradi_Click(object sender, EventArgs e)
{
int brojac = 0;
string grade = "";
string grading1 = "2";
string grading2 = "3";
string grading3 = "4";
string grading4 = "1";
string grading5 = "No Answer";
string grading6 = "5";
string grupa = "";
bool citaj = false;
bool mozda = false;
string odjel = "";
string pododjel = "";
string ocjenica = "";
int prviProlaz = 0;
foreach (DataRow redak in excelData.Rows)
{
if (prviProlaz > 0)
{
if (brojac == 0)
{
brojac = 1;
grupa = redak[1].ToString();
mozda = false;
citaj = false;
}
else
{
if (redak[1].ToString() == "")
{
mozda = true;
citaj = false;
}
else
{
if (redak[1].ToString() == "Agent Name")
{
citaj = true;
}
else if (redak[1].ToString() == grading1 || redak[1].ToString() == grading2 || redak[1].ToString() == grading3 || redak[1].ToString() == grading4 || redak[1].ToString() == grading5 || redak[1].ToString() == grading6)
{
grade = redak[1].ToString();
mozda = false;
}
else if (mozda == true)
{
brojac = 0;
}
else if (citaj == true)
{
if (grupa == "Team A" || grupa == "Team M" || grupa == "Team T")
{
pododjel = "AAAA";
odjel = "CCCC";
}
else if (grupa == "Team 1" || grupa == "Team 2")
{
pododjel = "BBBB";
odjel = "TTTT";
}
else if (grupa == "K Team" || grupa == "F Team")
{
pododjel = "RRRR";
odjel = "SSSS";
}
else if (grupa == "Group 1" || grupa == "Group 2" || grupa == "Group 3" || grupa == "Group 4")
{
pododjel = "FFFF";
odjel = "TTTTT";
}
else if (grupa == "Fun group 1" || grupa == "fun group 2" || grupa == "fun group 3" || grupa == "fun group 4" || grupa == "fun group 5")
{
pododjel = "KKKK";
odjel = "FFFF";
}
ocjenica = ocjenica.Trim();
preSort.Rows.Add(redak[0].ToString(), redak[1].ToString(), "", grade, Convert.ToDecimal(redak[4].ToString()), grade.Substring(0, 1), grupa, pododjel, odjel);
}
}
}
}
else
{
prviProlaz = 1;
}
}
dataGridView2.DataSource = preSort;
}