c# - 从程序集中检索 PDB

标签 c# reflection

通过 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/

相关文章:

c# - 将 sikuli 包含到 C# webdriver selenium

c# - Nest/ElasticSearch按_uid排序

.net - 程序集中的类列表

Java 6 注释带或不带参数重复

c# - 传递通用类型

c# - 最小化图像的内存消耗列表框(WPF)

c# - 将数组写入 Excel 范围

c# - 创建 SQLite 数据库和表

c# - 如何判断ParameterInfo是否为泛型?

java - 如何找到在给定类中实现其方法的 Java 接口(interface)?