Well, my solution is ugly, but it works, and I will continue MEF in the future (maybe). At the moment, I added this thing:
if(Path.GetFileNameWithoutExtension(dll)==Assembly.GetCallingAssembly().GetName().Name) continue;
Thanks everyone for the amazing answers.
EDIT: I came up with a more elegant solution, here it is:
var frameworkAssemblies = from file in new DirectoryInfo(frameworkDirectory).GetFiles() where (file.Extension.ToLower() == ".dll" || file.Extension.ToLower() == ".exe") && !AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).Contains(file.GetFileNameWithoutExtension()) select Assembly.LoadFrom(file.FullName);
source share