Assembly.GetReferencedAssemblies doesn't return all ref'd assemblies

M

Mike V

Why is it that the Assembly.GetReferencedAssemblies method returns an array
containing *some* of the referenced Assemblies, but not others? I have code
that depends on this functionality actually working. For example, I have a
CustomAssemblyA that references a CustomAssemblyB within Visual Studio, but
it doesn't show up as a reference when I call
CustomAssemblyA.GetReferencedAssemblies().

What do I need to do to get it to show up in the list?

Thanks,
Mike
 
J

Jon Skeet [C# MVP]

Mike V said:
Why is it that the Assembly.GetReferencedAssemblies method returns an array
containing *some* of the referenced Assemblies, but not others? I have code
that depends on this functionality actually working. For example, I have a
CustomAssemblyA that references a CustomAssemblyB within Visual Studio, but
it doesn't show up as a reference when I call
CustomAssemblyA.GetReferencedAssemblies().

What do I need to do to get it to show up in the list?

If you have a look at CustomAssemblyA in ILDASM, and look at the
manifest and the .assembly sections, does that show a reference to
CustomAssemblyB?
 
M

Mike V

I just fixed the problem, actually. I had to actually create a dummy object
of type CustomAssemblyB from within CustomAssemblyA in order to get it to
show up as a reference. (So now it's showing up in the manifest, to answer
your question.)

You might be wondering why I needed it if I never had a reference to it in
CustomAssemblyA. It's because I passed pointers to delegates defined in
CustomAssemblyB to CustomAssemblyB. That wasn't enough to get the manifest
to generate a reference to CustomAssemblyB though, I guess.

Thanks for your help!
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top