Ok ... i solved it! \o/
if any other guy has a similar problem, here's my code:
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(typeof(Kernel).Assembly));
foreach (var file in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory))
{
if (file.EndsWith(".dll"))
{
var tmpCatalog = new AggregateCatalog();
try
{
tmpCatalog.Catalogs.Add(new AssemblyCatalog(file));
CompositionContainer tmpContainer = new CompositionContainer(tmpCatalog);
tmpContainer.ComposeParts(this);
tmpContainer.Dispose();
catalog.Catalogs.Add(new AssemblyCatalog(file));
}
catch (ReflectionTypeLoadException rtlEx)
{
logger.Log(LogLevel.Error, "ReflectionTypeLoadException while trying to add " + file.ToString() + " : " + rtlEx.Message + "\r\n" + rtlEx.StackTrace);
foreach (Exception _ex in rtlEx.LoaderExceptions)
{
logger.Log(LogLevel.Error, " loader exception: " + _ex.Message + "\r\n" + _ex.StackTrace);
}
}
catch (Exception ex)
{
logger.Log(LogLevel.Error, "Exception while trying to add " + file.ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
}
}
}
_container = new CompositionContainer(catalog);
try
{
this._container.ComposeParts(this);
}
catch (CompositionException compositionException)
{
logger.Log(LogLevel.Error, "error at composing parts: " + compositionException.Message + "\r\n" + compositionException.StackTrace);
System.Windows.Forms.MessageBox.Show("error at composing parts: " + compositionException.Message + "\r\n" + compositionException.StackTrace);
}
catch (CompositionContractMismatchException contractMissmatchEx)
{
logger.Log(LogLevel.Error, "contract missmatch: " + contractMissmatchEx.Message + "\r\n" + contractMissmatchEx.StackTrace);
System.Windows.Forms.MessageBox.Show("contract missmatch: " + contractMissmatchEx.Message + "\r\n" + contractMissmatchEx.StackTrace);
}
catch (ReflectionTypeLoadException typeLoadEx)
{
logger.Log(LogLevel.Error, "type load exception: " + typeLoadEx.Message + "\r\n" + typeLoadEx.StackTrace);
System.Windows.Forms.MessageBox.Show("type load exception: " + typeLoadEx.Message + "\r\n" + typeLoadEx.StackTrace);
foreach (Exception _ex in typeLoadEx.LoaderExceptions)
{
logger.Log(LogLevel.Error, " loader exception: " + _ex.Message + "\r\n" + _ex.StackTrace);
System.Windows.Forms.MessageBox.Show(" loader exception: " + _ex.Message + "\r\n" + _ex.StackTrace);
}
}