在运行时从程序集获取变量的值 [英] Getting value of a variable from assembly during runtime

查看:87
本文介绍了在运行时从程序集获取变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


反射使我们能够在运行时查找程序集中的类型.以同样的方式,是否有可能在运行时从程序集中获取变量的值?

解决方案

如果您的意思是我是否可以在运行时访问另一个程序集中的变量的特定实例的值",则:否.它在它自己的内存空间中运行,除非提供了一种机制,否则您将无法访问它. /blockquote>

如果已生成调试信息并可用,则可以将调试器附加到正在运行的进程中.可在此处找到更多调试器信息/下载 http://www.microsoft.com/whdc/devtools/debugging /default.mspx [ ^ ]

您不能使用反射来简单地分配一个正在运行的进程并像监视自己的进程一样监视"它.对于.net dll,这是可能的,因为它们在同一进程中运行,但必须再次提供调试信息.顾名思义,反思就是对自己的看法.

祝你好运!


Hi,
Reflection enables us to find out the types in our assemblies during runtime.In the same way, Is it possible to get the value of a variable from a assembly during runtime?

解决方案

If you mean "can I access the value of a specific instance of a variable in another assembly at runtime" then: No. It runs in it''s own memory space and you cannot access it unless it provides a mechanism.


You could attach a debugger to a running process if debug info was generated and available. More debugger information/download can be found here http://www.microsoft.com/whdc/devtools/debugging/default.mspx[^]

You cannot use reflection to simply assign a running process and "watch" it as if it was your own. For orher .net dll this is possible however because they run in the same process but again debug information must be available. Reflection is, as the name implies, a view at yourself.

Good luck!


这篇关于在运行时从程序集获取变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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