如何调试通过Assembly.Load(byte [])加载的程序集? [英] How do you debug an assembly loaded through Assembly.Load(byte[])?

查看:135
本文介绍了如何调试通过Assembly.Load(byte [])加载的程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为使用Assembly.Load(byte[])加载插件DLL的产品创建插件.一切都很好,但这意味着我没有传统的加载调试符号来逐步执行代码的方法.

I am creating a plugin for a product that loads plugin DLLs using Assembly.Load(byte[]). This is all very well and good, but it means that I have no conventional means of loading the debugging symbols to step through my code.

疯狂的事情是,几个月前我遇到了完全相同的问题并解决了这个问题-男孩让我为自己感到骄傲!所以我知道可以做到的,我只是忘记了!

The crazy thing is, several months ago I was having the exact same issue and solved it - and boy was I proud of myself! So I know it can be done, I've just forgotten how!

对于可能尝试过的事情,我有一些模糊的记忆,但是我无法从脑海中挑出细节:

I have a few vague memories of things I might have tried, but I can't tease the details out of my head:

  • .NET反射器
    • 不过可能是错误的,因为我清楚地记得逐步浏览原始.cs文件
    • .NET Reflector
      • Probably wrong though because I distinctly remember stepping through the original .cs file
      • 但是这让我感到很奇怪,因为程序集是从字节数组加载的,因此框架不知道DLL的来源或适当的PDB(如果看到的话)会是什么样子.这个问题应该在任何环境中都存在.
      • 试过这个;我收到符号文件xxxxx.pdb与模块不匹配"的信息-因为,当然,我们是从字节数组而不是DLL本身加载的.

      推荐答案

      如果程序集具有强名称,则可以将该程序集放入GAC.即使是通过Assembly.Load(byte[])加载的,也始终从GAC加载强名称的程序集.然后只需将您的符号放在C:\Windows\symbols\dll中或方便的地方.我一直在进行调试,以调试我们自己产品的插件DLL,这些DLL由另一个应用程序以类似的方式加载.

      If your assembly is strongly named, you can put the assembly in the GAC. Strongly named assemblies are always loaded from the GAC, even if it is loaded via Assembly.Load(byte[]). Then just put your in symbols in C:\Windows\symbols\dll or where ever is convenient. I do this all the time to debug our own product's plugin DLLs which are loaded by another application in a similar manner.

      您可以使用gacutil将其安装在GAC中.切记在完成调试后将其删除,否则可能会针对GAC遗忘的旧版本进行测试.

      You can use gacutil to install it in the GAC. Remember to remove it when you're done debugging or you might end up running tests against an old version you GAC'd and forgot about.

      这篇关于如何调试通过Assembly.Load(byte [])加载的程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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