m0sa
m0sa

Reputation: 10940

Retrieiving PDB from Assembly

After loading an Assembly via Assembly.Load(byte[] rawAssembly, byte[] rawSymbolStore) is it possible to retrieve the rawSymbolStore data from the created Assembly instance? The call gets forwarded to this method, for which I can not see what it does..

[MethodImpl(MethodImplOptions.InternalCall)]
internal static RuntimeAssembly nLoadImage(byte[] rawAssembly, byte[] rawSymbolStore, Evidence evidence, ref StackCrawlMark stackMark, bool fIntrospection, SecurityContextSource securityContextSource);

What I want to do is to serialize an Assembly instance into the two byte arrays and send them over to an remote machine to be loaded there.

Upvotes: 2

Views: 470

Answers (1)

Hans Passant
Hans Passant

Reputation: 942090

is it possible to retrieve the rawSymbolStore data from the created Assembly instance?

No. The .pdb file for an assembly is a separate file on disk. It contains the debugging symbols for the assembly, you normally find it back in the build directory of your project. You can deploy the .pdb file along with the .dll but that's optional. It is only used to show file + line number info in an exception stack trace.

You must use a call like File.ReadAllBytes() to get the byte[] you need. The Assembly.Location property ought to be helpful to locate the .pdb file for the assembly. If you don't deploy it, or ReadAllBytes failed, then pass null for the second argument.

Upvotes: 1

Related Questions