Hi Allan,
Thanks for your feedback.
Yes, in this scenario, there is no direct reference relationship between
assembly A and B, so Assembly.GetReferencedAssemblies() called in assembly
A will not find assembly B.
The solution is using Assembly.GetEntryAssembly() method to get the first
root assembly(Exe) reference, and then recursively loop through all its
referenced assemblies Assembly.GetReferencedAssemblies(). Note1 : the
assembly A and B may not be directly referenced by the Exe, so you may need
to recursively loop through all the referenced assemblies again.
Note2 : during the recursively loop, you should take care of the redundant
assemblies checking, so that once an assembly is checked, it will not be
checked in the further loop and search.
Additionally, I am not sure your problem context. Have you considered to
use virtual function and polymorphism to resolve this problem as Joanna
pointed out? This may be more suitable solution.
If you have anything unclear or need any help, please feel free to
feedback. Thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.