for a given path, I want to load all of the assemblies so
that I can later walk the dependency graph. This function
works fine...
static void LoadAllAssembliesForPath(string path)
{
string[] files = Directory.GetFiles(path);
foreach(string x in files)
{
if(x.IndexOf(".dll") > 0 || x.IndexOf(".exe") > 0)
{
//try loading this file as an assembly
try
{
Assembly.LoadFile(x);
}
catch(Exception)
{ /* swallow */}
}
}
}
however, later in processing, when I call the Assembly.Load
(AssemblyName) function passing it an AssemblyName
reference resulting from Assembly::GetReferencedAssemblies
(), I get a FileNotFoundException.
Any idea why?
thanks,
_howard
Peter Koen - 24 Dec 2003 05:13 GMT
[...]
> however, later in processing, when I call the Assembly.Load
> (AssemblyName) function passing it an AssemblyName
> reference resulting from Assembly::GetReferencedAssemblies
> (), I get a FileNotFoundException.
Because assemblies loaded this way are not referenced assemblies. You have
to keep a list of dynamically loaded assemblies by your self.
beset thing is if you simply add the resulting assembly reference to an
arraylist and later check if it's included.
greets
Peter

Signature
------ooo---OOO---ooo------
Peter Koen - www.kema.at
MCAD MCDBA MCT
CAI/RS CASE/RS IAT
------ooo---OOO---ooo------