0

I've a WPF application that loads 3 different assembly which containts application extensions. I've added to the 3 projects the ModuleInit.Fody and for now just put a Console.WriteLine("module")

I load the assemblies with this piece of code

 var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "MyApplication.Modules*.dll");

        List<Assembly> assemblies = new List<Assembly>();

        foreach (var file in files)
        {
            AssemblyName assamblyName = AssemblyName.GetAssemblyName(file);

            var assembly = Assembly.Load(assamblyName); //this throw an exception
         //   AssemblyName name = new AssemblyName()
            //var assembly = Assembly.LoadFrom(file);

            assembly.GetTypes().First();
            assemblies.Add(assembly);
        }

What am I doing wrong? Thanks

UPDATE1 you can find a demo here

Community
  • 1
  • 1
advapi
  • 3,661
  • 4
  • 38
  • 73
  • What exception? What does it says? – Stas BZ May 27 '15 at 10:03
  • Additional information: Could not load file or assembly 'C:\\projects\\demo\\WPFComposition\\ModuleB\\bin\\Debug\\ModuleB.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) – advapi May 27 '15 at 10:15
  • If you can just download the project...it's 500kb – advapi May 27 '15 at 10:18

1 Answers1

2

A module initializer is run the first time any type from that assembly is used. NOT when the module is loaded

Simon
  • 33,714
  • 21
  • 133
  • 202