我将一个事件日志列表从windows froms放入dataGridView
,程序运行良好,或多或少做了它需要做的事情,但是它将它放入{{1}当我滚动浏览dataGridView
中的事件时,它会引发大量错误。
我不知道他们来自哪里或从哪里开始修复它们。 您可以滚动浏览事件,但它会抛出这些错误并继续运行。
dataGridView
public static class EventLogClassContainer
{
public static string EvlLocation { get; set; } = "";
public static string EvlName { get; set; } = "Application";
public static string evlLocationManual = "%Test.evt%";
public static List<EventLogEntry> _LogEntries { get; private set; }
public static void ReadEventLog()
{
EventLog evlLog = new EventLog(EvlName, ".");
EventLogEntryCollection eventLogEntries = evlLog.Entries;
int eventLogEntryCount = eventLogEntries.Count;
foreach (EventLogEntry entry in evlLog.Entries)
{
//entry.Message
_LogEntries = eventLogEntries.Cast<EventLogEntry>().ToList();
}
}
public static void SetEvlName(string evlLocation)
{
Parser.FileNameFinder(evlLocation, 3);
}
public static void RELSystemTest()
{
EventLog evlLog = new EventLog("Application", ".");
EventLogEntryCollection eventLogEntries = evlLog.Entries;
int eventLogEntryCount = eventLogEntries.Count;
_LogEntries = eventLogEntries.Cast<EventLogEntry>().ToList();
}
public static void ParseTest()
{
evlLocationManual = "K:\\Event Log\\Test\\Test.evt";
ReadEventLog();
}
public static void setLogLocation(string input)
{
EvlLocation = input;
}
}
以下例外情况:
DataGridView中发生以下异常:
System.ArgumentException:参数无效。在System.Drawing.Image.FromStream(Stream stream,Boolean useEmbeddedColorManagement,Boolean validateImageData)
at
System.Drawing.ImageConverter.ConvertFrom(ITypeDescriptionContext context,CultureInfo culture,Object value)
在
System.Windows.Forms.Formatter.FormatObject(Object value,Type targetType)中的System.Windows.Forms.Formatter.FormatObjectInternal(Object value,Type targetType.TypeConverter sourceConverter,TypeConverter targetConverter,String formatString,IFormatProvider formatInfo,Object formattedNullValue) ,TypeConverter sourceConverter,TypeConverter targetConverter,String formatString,IFormatProvider formatInfo,Object formattedNullValue,Object dataSourceNullValue)在
System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value,Int32 rowIndex,DataGridViewCellStyle&amp; cellStyle,TypeConverter valueTypeConverter,TypeConverter formattedValueTypeConverter,DataGridViewDataErrorContexts context)
要替换此默认对话框,请处理DataError事件。
DataGridView中发生以下异常:
System.ArgumentException:值'0'不是枚举'EventLogEntryType'的有效值。
在
System.ComponentModel.EnumConverter.ConvertTo(ITypeDescriptorContext context,CultureInfo culture,Object value,Type destinationType)
在
System.Windows.Forms.Formatter.FormatObject(Object value,Type targetType)中的System.Windows.Forms.Formatter.FormatObjectInternal(Object value,Type targetType.TypeConverter sourceConverter,TypeConverter targetConverter,String formatString,IFormatProvider formatInfo,Object formattedNullValue) ,TypeConverter sourceConverter,TypeConverter targetConverter,String formatString,IFormatProvider formatInfo,Object formattedNullValue,Object dataSourceNullValue)在
System.Windows.Forms.DataGridViewCell.GetFormattedValue(Object value,Int32 rowIndex,DataGridViewCellStyle&amp; cellStyle,TypeConverter valueTypeConverter,TypeConverter formattedValueTypeConverter,DataGridViewDataErrorContexts context)
要替换此默认对话框,请处理DataError事件。
答案 0 :(得分:0)
在视频中,您的某些列定义似乎与文件内容不匹配。其中一列似乎是期待图像或图标,但可能正在获得某种类型的索引。另一列正在尝试将文件值转换为枚举,但值“0”不在枚举中。