此错误仅发生在某些计算机上。通过读取堆栈信息,当我在静态类中调用此静态方法(“FormatQuery”)时出现一些问题:
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using FlexCel.Report;
using FlexCel.XlsAdapter;
using ComboBox=System.Windows.Forms.ComboBox;
namespace XSoftArt.A
{
static class RHelper
{
private static string FormatQuery(string FieldName, int Count,
CheckedListBox chekedListBox)
{
string ID = string.Empty;
int n = Count;
foreach (DataRowView item in chekedListBox.CheckedItems)
{
ID = ID + item["" + FieldName + ""];
if (n > 1)
{
ID = ID + " , ";
n--;
}
}
return ID;
}
public static string FormatQuery(CheckedListBox chekedListBox)
{
return FormatQuery(chekedListBox.ValueMember,
chekedListBox.CheckedItems.Count, chekedListBox);
}
}
所以有什么问题?我该如何解决?调试模式的项目配置有问题还是什么?
错误信息:
at XSoftArt.EVS.ReportHelper.FormatQuery(CheckedListBox chekedListBox)
at XSoftArt.EVS.NewEmailSelectClient.LoadList_v2(String search, TextBox txtbox)
at XSoftArt.EVS.NewEmailSelectClient.LoadContacts()
at XSoftArt.EVS.NewEmailSelectClient.button7_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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)
类型初始值设定项异常表示无法创建该类型。当您简单地引用该类时,这通常会在调用方法之前发生。
您这里的代码是您类型的完整文本吗?我会寻找类似作业失败的东西。我在获取应用程序设置和类似性质的事情时经常看到这种情况。
static class RHelper
{
//If this line of code failed, you'd get this error
static string mySetting = Settings.MySetting;
}
您还可以通过类型的静态构造函数看到这一点。
无论如何,这堂课还有更多吗?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)