vendredi 12 avril 2019

Get path to all referenced Assemblies from external Assembly

I'm attempting to create a method which allows the user to select any assembly. Running this will then show all the paths to the referenced assemblies within this selected assembly.

I first create a new AppDomain and use the ResolveEventHandler.

I then get the assemblyPath from the selected assembly using OpenFileDialog:

Assembly selectedAssembly.LoadFrom(assemblyPath);
AssemblyName[] assemblyNames = selectedAssembly.GetReferencedAssemblies();

foreach (AssemblyName assembly in assemblyNames)
    {
        Assembly currentAssembly = Assembly.Load(assembly);
        string assemblyLocation = currentAssembly.Location;
    }

The problem is, only assemblies which are referenced in the current project can be found and therefore loaded.

Is there any way to get the path of all of the referenced assemblies from a selected dll?





Aucun commentaire:

Enregistrer un commentaire