有没有办法在我自己的应用程序中使用 Visual Studio 的监视窗口?

发布于 2024-08-21 00:18:37 字数 232 浏览 10 评论 0原文

我有一个基本的消息传递应用程序,它接受来自客户端的请求并向它们返回响应对象。当我遇到格式错误的请求对象时,我将其序列化到数据库日志中,以查找二进制字段中的失败请求。我希望能够反序列化这些格式错误的请求对象并在事后检查它们。

有没有办法在我自己的应用程序中使用 Visual Studio Watch 窗口(或类似的窗口)?我知道属性网格,这就是我现在正在使用的,但是使用监视窗口来检查对象会很酷,因为监视窗口是大多数开发人员所熟悉的。

I have a basic messaging application that takes requests from clients and returns them response objects. When I encounter a malformed request object I serialize it to a database log for failed requests in a binary field. I'd like to be able to deserialize these malformed request objects and inspect them after the fact.

Is there a way to use the Visual Studio Watch window (or something like it) in my own app? I'm aware of the property grid and that's what I'm using for now but it'd be cool to use the watch window to inspect the objects since the watch window is what most of the developers are familiar with.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

李白 2024-08-28 00:18:37

使用 Visual Studio 本身怎么样?您已经知道如何序列化(因此我假设反序列化)该对象。为什么不编写一个应用程序来反序列化它,然后将 VS 调试器连接到该应用程序?

How about using Visual Studio itself? You already know how to serialize (and so I presume deserialize) the object. Why not write an app to deserialize it and then hook up the VS debugger to that app?

笑饮青盏花 2024-08-28 00:18:37

我将使用 PropertyGrid 控件。它可用于一次检查单个对象。

I would use the PropertyGrid control. It can be used to inspect a single object at a time.

榕城若虚 2024-08-28 00:18:37

与属性网格相比,您更喜欢监视窗口中的什么?是评估自定义表达式的能力,还是只是 UI 的能力?

如果是前者,那么,

我不知道任何现成的东西可以让你做到这一点,最接近的东西(不附加调试器)是 Crack.NET(请参阅这张图片),理论上您可以将该脚本窗口合并到您自己的项目中(毕竟它是开源的),但是您必须用 Python 而不是 C# 编写表达式。

至于更自助的方法,您可以使用 CodeDom 将表达式编译为如下所示的方法:

object Evaluate(RequestObject request)
{
     return   ... your expression goes here ... ;
}

然后加载您自动编译的 DLL 来动态调用该方法,然后在属性中呈现其返回值网格,如果你喜欢的话。

What is it that you prefer in the Watch Window over the property grid? Is it the ability to evaluate custom expression, or just it's UI?

If it is the former, then,

I don't know anything out of the box that will let you do this, the thing that comes the closest (without attaching a debugger) is Crack.NET (see this picture), and you could theoretically incorporate that script window into your own project (it's open source, after all), but then you'd have to write your expressions in Python, not C#.

As for a more do-it-yourself approach, you could use CodeDom to compile your expression into a method that looks like:

object Evaluate(RequestObject request)
{
     return   ... your expression goes here ... ;
}

And then load the DLL you have automatically compiled to dynamically call this method, and then present its return value in the property grid if you like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文