通过 Assembly.Load(byte[] rawAssembly, byte[] rawSymbolStore)
加载一个 Assembly 后,是否可以从创建的 Assembly 实例中检索 rawSymbolStore 数据?调用被转发到这个方法,我看不到它做了什么..
[MethodImpl(MethodImplOptions.InternalCall)]
internal static RuntimeAssembly nLoadImage(byte[] rawAssembly, byte[] rawSymbolStore, Evidence evidence, ref StackCrawlMark stackMark, bool fIntrospection, SecurityContextSource securityContextSource);
我想做的是将一个 Assembly 实例序列化为两个字节数组,并将它们发送到远程机器以在那里加载。
最佳答案
is it possible to retrieve the rawSymbolStore data from the created Assembly instance?
没有。程序集的 .pdb 文件是磁盘上的一个单独文件。它包含程序集的调试符号,您通常可以在项目的构建目录中找到它。您可以将 .pdb 文件与 .dll 一起部署,但这是可选的。它仅用于在异常堆栈跟踪中显示文件 + 行号信息。
您必须使用 File.ReadAllBytes() 之类的调用来获取所需的 byte[]。 Assembly.Location 属性应该有助于找到程序集的 .pdb 文件。如果您不部署它,或者 ReadAllBytes 失败,则为第二个参数传递 null。
关于c# - 从程序集中检索 PDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14598848/