I am trying to get this convention configuration working but I am having a problem in my ASP.NET MVC5 Project..
I have added the following in my Application_Start method and hooked it up to DependencyResolver
public static IUnityContainer CreateContainer()
{
IUnityContainer container = new UnityContainer();
container.RegisterTypes(
AllClasses.FromAssembliesInBasePath(),
WithMappings.FromAllInterfaces,
WithName.Default,
WithLifetime.ContainerControlled);
return container;
}
But it fails to register any types, on closer inspection, when I see whats in AllClasses.FromAssembliesInBasePath() it always runs null or empty.
Am I doing something wrong? is there a better place I should put this?
Thanks. Ste.
The reason might be that the domain base path is not what you thought.
Please try this see if it registers anything:
container.RegisterTypes(
AllClasses.FromAssemblies(Assembly.GetExecutingAssembly()),
WithMappings.FromAllInterfaces,
WithName.Default,
WithLifetime.ContainerControlled);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With