关于.NET:logParser在C#中无错误崩溃

LogParser crashes without error in C#

我正试图在C应用程序中实现MS LogParser。这会编译logquery.executeBatch()方法上的细微但无法解释的崩溃。Try/Catch块不会捕获它,除非我对szQuery进行了专门的变形,这表明一切都正常工作,我只是没有得到任何输出。

有没有想过它为什么会崩溃,或者我在哪里可以找到一些日志?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</p>

<p>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FolderLoggingLib;
using MSUtil;
</p>

<p>
namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            //refLog = new BinaryInputFormat();
            LogQueryClass logQuery = new LogQueryClass();
            ICOMCSVOutputContext output = new COMCSVOutputContextClass();
            ILogParserInputContext parse = new BinaryInputFormat();
</p>

<wyn>        string szFileName = @"E:\Programming\FolderLogging\2012-05-13.fbl";
        string szQuery ="SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation, Checked FROM" + szFileName +" ORDER BY DateTime DESC";
        try
        {
            logQuery.ExecuteBatch(szQuery, parse, output);
        }
        catch
        {
        };          
    }
}

}


使用Execute而不是ExecuteBatch:

1
MSUtil.ILogRecordset RecordSet = logQuery.Execute(query, oInputFormat)

如果要在示例代码中导出到csv,则需要通过添加到输出文件名并运行executeBatch来更改查询:

1
string szQuery ="SELECT Folder, User, Record, DB, TO_LOCALTIME(Timestamp) AS DateTime, Operation,  Checked **INTO c:\out\out.csv** FROM" + szFileName +" ORDER BY DateTime DESC";