【发布时间】:2014-06-05 00:48:54
【问题描述】:
我对 postsharp 比较陌生,但我确实在 postsharp 的帮助下使用 entlib、log4net、异常日志记录和异常屏蔽为异常日志记录编写了一些不错的方面。这对我目前使用的所有东西来说都是非常简单和有用的东西。
但是当我尝试注入一个方面以在 catch{} 之后立即记录异常时,即使异常被吞下,我也找不到方法。
说我不能更改目标代码也许很有用。一切都必须在方面做。我确实使用派生的 OnExceptionAspect 成功记录了未被吞咽的异常。
我曾想过用 postsharp sdk 注入 MSIL,但不喜欢这条路。
例如
public IList<DatabaseTable> GetDataTables()
{
try
{
if (this._databaseTables == null)
this._databaseTables = this.LoadTablesFromDatabase();
return _databaseTables;
}
catch // swallowed exception
{
// I want to log here!
// other conpensation stuffs....
}
}
有什么想法吗?
谢谢
【问题讨论】:
标签: postsharp