all groups > dotnet clr > december 2003 >
You're in the

dotnet clr

group:

Assembly.LoadFile(..) -- assembly loaded but not found later


Assembly.LoadFile(..) -- assembly loaded but not found later howard dierking
12/23/2003 2:27:31 PM
dotnet clr:
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,

Re: Assembly.LoadFile(..) -- assembly loaded but not found later Peter Koen
12/23/2003 9:13:17 PM
"howard dierking" <anonymous@discussions.microsoft.com> wrote in
news:021b01c3c9a3$f4c52980$a501280a@phx.gbl:

[...]
[quoted text, click to view]

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

--
------ooo---OOO---ooo------

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

AddThis Social Bookmark Button