Is a good idea to loading referenced assemblies like this:
public void Load(string assemblyFilePath)
{
var assembly = Assembly.LoadFrom(assemblyFilePath);
string assemblyDirectory = Path.GetDirectoryName(assemblyFilePath);
var assembliesFilesPaths = Directory.GetFiles(assemblyDirectory, "*.dll");
var referencedAssembliesNames = assembly.GetReferencedAssemblies();
foreach (var referencedAssembliesName in referencedAssembliesNames)
{
var assemblyPath = assembliesFilesPaths.FirstOrDefault(path => Path.GetFileNameWithoutExtension(path) == referencedAssembliesName.Name);
if (string.IsNullOrEmpty(assemblyPath))
continue;
Assembly.LoadFrom(assemblyPath);
}
}
I would like to load assembly and have access to types which are defined in another (referenced) assembly.
Aucun commentaire:
Enregistrer un commentaire