Skip to content

Commit

Permalink
search AppDomain for Container
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Dec 2, 2020
1 parent 4355455 commit 7ab82bb
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -32,8 +33,10 @@ public static IContainerExtension LocateContainer(IContainerExtension container
ContainerLocator.ResetContainer();
}

var entryAssembly = Assembly.GetEntryAssembly();
var containerAttributes = entryAssembly.GetCustomAttributes().OfType<ContainerExtensionAttribute>();
var containerAttributes = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x.GetCustomAttributes<ContainerExtensionAttribute>().Any())
.Select(x => x.GetCustomAttribute<ContainerExtensionAttribute>())
.Distinct();

if (!containerAttributes.Any())
throw new InvalidOperationException("An instance of the IContainerExtension has not been registered with the ContainerLocator, and no ContainerExtensionAttribute has been found in the entry assembly.");
Expand Down

0 comments on commit 7ab82bb

Please sign in to comment.