I have a class:
public abstract class XTimeViewModel : DevExpress.Xpf.Mvvm.ViewModelBase { public bool PropertiesChanged { get; set; } [NotifyPropertyChangedInvocator] protected virtual void _onPropertyChanged( string propertyName = null) { PropertiesChanged = true; RaisePropertyChanged(propertyName); } }
It is contained in an assembly called Common . When I try to add DirectoryCatalog for the folder with Common and other assemblies and dependencies such as DevExpress.Xpf.Mvvm.v13.2 :
var catalog = new DirectoryCatalog(unitPath, "*.dll"); AggregateCatalog.Catalogs.Add(catalog);
I get a ReflectionTypeLoadException , with a TypeLoadException indicating:
"Failed to load type 'Startup.ViewModels.ViewModel' from assembly 'G4S.XTime.Common, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = zero." "
I do not understand why MEF cannot load this type. When I try the sample code:
var asm = Assembly.LoadFrom(@"C:\Development\XTime\Startup\Units\G4S.XTime.Common.dll"); var vm = asm.GetType("G4S.XTime.Common.XTimeViewModel");
Then vm contains the correct type, i.e. G4S.XTime.Common.XTimeViewModel .
Just a hunch, but none of my loaded modules have Initialize , and I think this error is close to the root cause of this.
If I refer to the modules and use AssemblyCatalog to load them, there is no problem, and everything works as it should. What could make the assembly load at runtime to stop it?
BTW, Common not the module itself, but simply the dependency of several modules.