Loading assemblies

    Date: 10/12/05 (C Sharp)    Keywords: no keywords

    I'm sure I'm missing something simple here. I've created a dll containing a trivial c# class:

    
    namespace Library
    {
        public class Foo
        {
            public static string Name()
            {
                return "Foo";
            }
        }
    }
    

    Now I'm trying to open it and find the class using reflection. Given that dir is a System.IO.DirectoryInfo with the directory listing in it, the code I'm using to open the dll (I've stripped out the error checking) is:
    
    System.IO.FileInfo[] files = dir.GetFiles("*.dll");
    foreach (System.IO.FileInfo fi in files)
    {
    	string filename = fi.FullName;
                    System.Reflection.Assembly a = System.Reflection.Assembly.Load(filename);
    	// etc.
    


    But the attempt to load the assembly gives:
    System.IO.FileLoadException was unhandled
      Message="The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"

    According to the help, that means that it could find the file, but it wasn't a valid assembly.

    So what do I need to do to make it a valid assembly?

    Source: http://www.livejournal.com/community/csharp/38098.html

« Outgoing packets || Is there any LPT API? »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home