Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2003

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
howard dierking - 23 Dec 2003 22:27 GMT
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------


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.