diff --git a/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs b/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs index 8c5bb0223..5775fc9ba 100644 --- a/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs +++ b/src/Orchard/Environment/Extensions/ExtensionLoaderCoordinator.cs @@ -227,6 +227,24 @@ namespace Orchard.Environment.Extensions { string referenceName, IList activatedReferences) { + // If the reference is an extension has been processed already, use the same loader as + // that extension, since a given extension should be loaded with a unique loader for the + // whole application + var bestExtensionReference = context.ProcessedExtensions.ContainsKey(referenceName) ? + context.ProcessedExtensions[referenceName] : + null; + + // Activated the extension reference + if (bestExtensionReference != null) { + activatedReferences.Add(new DependencyReferenceDescriptor { + LoaderName = bestExtensionReference.Loader.Name, + Name = referenceName, + VirtualPath = bestExtensionReference.VirtualPath + }); + + return; + } + // Skip references from "~/bin" if (_buildManager.HasReferencedAssembly(referenceName)) return; @@ -243,20 +261,6 @@ namespace Orchard.Environment.Extensions { .ThenBy(e => e.Entry.Name) .FirstOrDefault(); - var bestExtensionReference = context.ProcessedExtensions.ContainsKey(referenceName) ? - context.ProcessedExtensions[referenceName] : - null; - - // Pick the best one of module vs binary - if (bestExtensionReference != null && bestBinaryReference != null) { - if (bestExtensionReference.LastWriteTimeUtc >= bestBinaryReference.LastWriteTimeUtc) { - bestBinaryReference = null; - } - else { - bestExtensionReference = null; - } - } - // Activate the binary ref if (bestBinaryReference != null) { if (!context.ProcessedReferences.Contains(bestBinaryReference.Entry.Name)) { @@ -270,15 +274,6 @@ namespace Orchard.Environment.Extensions { }); return; } - - // Activated the module ref - if (bestExtensionReference != null) { - activatedReferences.Add(new DependencyReferenceDescriptor { - LoaderName = bestExtensionReference.Loader.Name, - Name = referenceName, - VirtualPath = bestExtensionReference.VirtualPath - }); - } } private void ProcessContextCommands(ExtensionLoadingContext ctx) {