I am registering my types by convention, but some types from my other assemblies are not registering consistently. Sometimes they are registered, while other times they aren't. It's not consistently failing. Here's some trace data:
...is an interface and cannot be constructed. Are you missing a type mapping?
I want to eliminate 3rd party dlls and such from my registration process. Is this the right way to do this?
public static class UnityConfig
{
public static void RegisterComponents()
{
var container = new UnityContainer();
container.RegisterTypes(
AllClasses.FromLoadedAssemblies().Where(t => t.Namespace != null && t.Namespace.StartsWith("MY NAMESPACEs ONLY")),
WithMappings.FromMatchingInterface,
WithName.Default);
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
}
EDIT: This also randomly happens when I remove the "Where" filter. I've used this registration methodology before and this NEVER happened. What's going on?