在 C#/.NET 中记录对文件的方法调用的最佳方法? [英] Best way to record method calls to a file in C#/.NET?

查看:81
本文介绍了在 C#/.NET 中记录对文件的方法调用的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为一些生成条形码和标签图形的代码编写一个可视化工具.我想要这样做的方法是将正在运行的方法+参数记录到一个文件中,这样我就可以回放它们并查看每个阶段生成的可视化输出(因此是一种可视化调试器来帮助我解决测量问题图)

I'm trying to write a visualiser for some code which generates graphics for barcodes and labels. The way I want to do this is by recording the methods+parameters being run to a file, so I can play them back and see the visual output generated at each stage (so a kind of visual debugger to help me fix issues with measurements in the drawing)

我可以访问这些方法,我可以在其中放入任何我喜欢的东西 - 但我一直坚持记录被调用的方法签名和参数的最佳方式,尤其是因为其中很多都是重载等.

I have access to the methods, and I can put anything I like in them - but I'm stuck on the best way to record the method signature being called and the parameters, especially since a lot of them are overloads etc.

有什么简单的方法可以帮助我序列化/记录实际的方法调用信息吗?(为了重播它,所以我需要以编程方式加载信息并调用它)也许与反射相关的东西?

Is there anything simple that will help me serialize/record actual method call information? (with a view to replay it back, so I need to programmatically load the information and call it) Perhaps something reflection-related?

注意:我是我正在从事的项目的实习生,我可能不允许在构建中引入新的程序集等,所以我认为需要库的基于方面的东西已经过时了.(同时,我不只是在问一个问题.我应该弄清楚自己 - 这更像是我在午休时间做的额外事情来帮助我的主要任务)

Note: I'm an intern on the project I'm working on, and I'm probably not allow to introduce new assemblies etc. into the build, so I think aspect-based things requiring libraries are out. (At the same time, I'm not just asking a Q. I should be figuring out myself - this is more an additional thing I'm doing during my lunch break to help my main task)

推荐答案

从现有的分析器作为基础开始可能是个好主意 - 例如来自 http://code.google.com/p/slimtune/

It might be a good idea to start from an existing profiler as a base - e.g. from http://code.google.com/p/slimtune/

请注意,分析器本身非常复杂——对于 .Net,它们需要一些 C++/COM 知识——但是如果你从像 slimtune 这样的基础开始,那么希望你能够避免使用这个核心代码,而是能够专注于您自己的可视化需求.

Note that profilers themselves are quite complicated - for .Net they require some C++/COM knowledge - but if you start from a base like slimtune, then hopefully you'll be able to avoid this core code and will instead be able to focus on your own visualisation requirements.

这篇关于在 C#/.NET 中记录对文件的方法调用的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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