我怎样才能跟踪()添加到在C#中的每一个方法调用? [英] How can I add a Trace() to every method call in C#?

查看:163
本文介绍了我怎样才能跟踪()添加到在C#中的每一个方法调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很难跟踪锁定的问题,所以我想记录每个方法调用的进入和退出。我在此之前用C ++做,而不必code添加到每个方法。这可能与C#?

I am having a hard time tracking down a lock issue, so I would like to log every method call's entry and exit. I've done this before with C++ without having to add code to every method. Is this possible with C#?

推荐答案

可能是你最好的选择将是使用AOP(面向方面​​编程)框架自动调用前一个方法执行后的跟踪code。为AOP和.NET一个流行的选择是 PostSharp

Probably your best bet would be to use an AOP (aspect oriented programming) framework to automatically call tracing code before and after a method execution. A popular choice for AOP and .NET is PostSharp.

这篇关于我怎样才能跟踪()添加到在C#中的每一个方法调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆