我已經在PCL中引用了一些ETW代碼,並在一個已運行數月的Windows 8.1應用程序中使用。具體而言,這行代碼:ETW - Windows 8.1 - EventWrittenEventArgs有效負載丟失數據
WriteEvent((int)errorId, message, (useSysLog ? sysLogErrorId : SysLogSeverity.NotSpecified));
已經發送對象來EventWrittenEventArgs
的Payload
特性的陣列中的我的我的EventListener
的OnEventWritten
功能。
我會得到一個Payload
與Count
爲2,它將包含一個string
和SysLogSeverity
實例。
我最近將我的Visual Studio升級到2015,現在我的Payload
只包含一個屬性 - string
。 SysLogSeverity
不再通過OnEventWritten
。
升級到VS2015是我的問題嗎?升級發生時,ETW代碼所在的庫不會更改。我檢查了我的項目的git歷史記錄,並且沒有更改彙編版本。
我不知道爲什麼會發生這種情況,並真的很感激任何關於如何調試/可能發生的想法。
更新:
這裏是我的助手方法是什麼樣子的是調用了WriteEvent
功能:
[NonEvent]
private void _WriteEvent(int errorId, string message, SysLogSeverity sysLogSeverity)
{
if (_errorLevelsMap.ContainsKey((ErrorIds)errorId))
{
sysLogSeverity = _errorLevelsMap[(ErrorIds)errorId];
}
if (this.IsEnabled())
{
WriteEvent((int)errorId, message, sysLogSeverity);
}
}
這裏的_errorLevelsMap的定義:
private readonly Dictionary<ErrorIds, SysLogSeverity> _errorLevelsMap = new Dictionary<ErrorIds, SysLogSeverity>
{
{ ErrorIds.Critical, SysLogSeverity.Critical },
{ ErrorIds.Error, SysLogSeverity.Error },
{ ErrorIds.Informational, SysLogSeverity.Informational },
{ ErrorIds.Verbose, SysLogSeverity.Debug },
{ ErrorIds.Warning, SysLogSeverity.Warning }
};
簽名匹配,仍然,Payload
只包含message
;不是sysLogErrorId
。
謝謝!
哦,我的。這非常有趣。目前,簽名不匹配。我會稍微嘗試一下。 你知道這是否是一項新要求嗎? –
我從來沒有使用.net的內部EcentSource我總是使用NuGet版本,在這裏它始終是必需的。 https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventSource – magicandre1981
我忘了提及ETW代碼是在PCL中;我無法使用nuget包。我會更新OP。 –