How to get the physical path of reference assemblies

I have one main assembly, this assembly refers to another assembly. I can get these reference names. But I cannot restore the physical path of these referenced assemblers. Can anyone help me with this?

I am using the following code.

string path = Path.GetFullPath(txtFileName.Text); Assembly a = Assembly.LoadFrom(path); foreach (AssemblyName an in a.GetReferencedAssemblies()) { Assembly asm = Assembly.Load(an); MessageBox.Show(an.FullName.ToString() + "Location : " + asm.CodeBase.ToString()); } 

This gives me the build path of the mscorlib system. But when he tries to retrieve the custom assembly, he says: "The system cannot find the specified file."

+4
source share
1 answer

Perhaps so:

 string path = System.Reflection.Assembly.GetAssembly(typeof(asm)).Location; string dir = Path.GetDirectoryName( path); 
+4
source

Source: https://habr.com/ru/post/1486186/


All Articles