c# - Get pathes of assemblies used in Type -


I need a method that takes one type and returns to the patent of all the assemblies used in the type. I have written it:

  Public stable IEnumerable & lt; String & gt; GetReferencesAssembliesPaths (type of this type) {yield returns type. Assembly. place; Foreign Language (assembly name assembly type in. Assembly GetReferencedAssemblies ()) {yield return assembly. Load (assembly name). place; Generally, this method works, but there are some disadvantages:  
  • I did not find how to get referenced assemblies / types only, so I typed. The Assembly referred to the context referred problem () and the entire assembly, not just those related to those types.

  • Type assembly.GetReferencedAssemblies () gives assembly name and does not contain any location / path / file path property. To get the property of the place, I used assembly.Load () first and then used the property of the place. I do not need to load my assemblies, because they were not necessary and could fail with the Assembly.Load () FileNotFoundException or BadImageFormatException.

    Any suggestions?

    Now this is the way how my approach looks:

      public static IEnumerable & Lt; String & gt; GetReferencesAssembliesPaths (type of this type) {yield returns type. Assembly. place; Type the name in the Foreign Language Assembly (assembly name assembly. GetReferencedAssemblies ()) {yield return assembly. ReflectionOnlyLoad (assemblyName.FullName). place; }}  

    Now the only left problem is type.Assembly.GetReferencedAssemblies (), how do I get to refer to assemblies by type instead of assembly?


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -