HowTo: Detect Assembly dependencies at runtime

I'm currently developing a small project for myself, where I'm trying to build a small plugin framework (for experimenting purposes). In that environment I just came across the problem of detecting an assemblies dependencies at runtime. And actually to my surprise it is easier as I expected.
  1. Retrieve an instance of the current assembly. Either you have it already or it can be retrieved with

    Assembly currentAssembly = Assembly.GetExecutingAssembly();
  2. Then get all of it's referenced assemblies

    AssemblyName[] referencedAssemblies = currentAssembly.GetReferencedAssemblies();
This will give you a list of referenced assemblies which can then be instantiated in the way it is needed.
Kindle

Comments

0

Your ad here?