I need to get a list of assemblies in a directory. Is there another way than this?
System.IO.Directory.GetFiles(directory, '*.dll')
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Managed assemblies can also be EXEs. And your code just gets files with the extension ‘dll’. Ntive DLLs, which are not assemblies, would also be returned.
In the few occasions I needed to do this, I simply got a list of all files (similar to what you’ve done), and then used Assemby.LoadFrom to attempt to load each, trappig the exception in the event its native. The typical exception is a ReflectionTypeLoadException, though you also may get this if a reference can’t be resolved.