统一3配置按照惯例没有找到网络中的项目类型 [英] Unity 3 Configuration By Convention not finding Types in Web Project
问题描述
我试图让这个约定的配置工作,但我有我的ASP.NET MVC5项目有问题。
I am trying to get this convention configuration working but I am having a problem in my ASP.NET MVC5 Project..
我已经加入我的Application_Start方法如下,并迷上它高达DependencyResolver
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;
}
但它未能注册任何类型的,仔细观察,当我在AllClasses.FromAssembliesInBasePath(见什么),它总是运行空。
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);
这篇关于统一3配置按照惯例没有找到网络中的项目类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!