CLR分析API:是否可以读取对象方法参数并在C#中重新创建它? [英] CLR Profiling API: Is it possible to read an object method paremeter and recreate it in C# ?

查看:229
本文介绍了CLR分析API:是否可以读取对象方法参数并在C#中重新创建它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

首先,请问如果这是该主题的论坛不正确,但是我还没有找到更合适的论坛.

first of all excuse me if this is the wrong forum for that topic but i have not found one thats more suitable.

我正在尝试.NET CLR分析API.假设有一个C#方法,其中有一个对象作为参数.因此,当CLR为该方法调用EnterFunction3WithInfo时,可能会从内存中读取该参数的数据,然后进行传输 使用命名管道(或其他IPC机制)将其添加到另一个C#应用程序并重新创建".从那里的数据中找到对象?

I'm experimenting with the .NET CLR Profiling API. Let's assume there is a C# method with an object as parameter. So when the CLR calls EnterFunction3WithInfo for that method, would it be possible, to read the data for that parameter form the memory, transfer it with a named pipe (or other IPC mechanisms) to another C# application and "recreate" the object from that data there?

我不认为这是可能的,但是我不是专家,并且想确定在放弃这个想法之前. :>

I do not believe that this is possible, but I'm not an expert and would like to be sure before I give up that idea. :>

推荐答案

我认为在技术上有可能达到受限的程度,但几乎可以肯定不切实际

I believe it's technically possible to a limited degree, but is almost certainly not practical.

可能出现的一些问题包括:

Some of the problems that would arise include:

  • 确保IPC的两端都使用相同版本的所有程序集(以防字段更改).
  • 如果对象包含指针大小的字段(IntPtr,UIntPtr,void *),该怎么办?等)并从64位进程复制到32位进程?
  • 如果源对象包含本机资源引用怎么办? (虚拟地址,句柄等)
  • 如果对象形成循环对象图的一部分怎么办?
  • 如果对象多次传递,该怎么办? (您是否传递了引用前一个对象的某种标识符?还是重新复制了对象图?如果对象图发生了更改该怎么办?)
  • 如果遇到一个哈希表(该类型用作键)怎么办?是不覆盖GetHashCode的引用类型?

如果您只想复制一些复杂性非常有限的特定对象类型,那可能就可以了,但是在这种情况下,我建议您只复制所需的特定值,而不必重新创建它.

It might be 'ok' if you only want to copy a few specific object types of very limited complexity, but in such cases I would suggest you just copy the specific values you want and forget about recreating it.


这篇关于CLR分析API:是否可以读取对象方法参数并在C#中重新创建它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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