ReadEvent():“传递给系统调用的数据区域太小”

Flo*_*ssn 5 .net c# logging

在尝试读取 Windows 日志时,我有时会收到带有消息的 EventLogException:“传递给系统调用的数据区域太小”。我几乎从 msdn 中复制了这个例子。

EventRecord eventInstance = null;
            try
            {
                eventInstance = logReader.ReadEvent();
            }
            catch (EventLogException e)
            {
                //...
            }
Run Code Online (Sandbox Code Playgroud)

我看不到错误发生的时间和原因。