由网友(云起兮衣飞扬)分享简介:我的code如下:IUnityContainer container = new UnityContainer(); container.ConfigureAutoRegistration().LoadAssemblyFrom(typeof(Test).Assembly.Location).LoadAssemb...
我的code如下:
IUnityContainer container = new UnityContainer();
container
.ConfigureAutoRegistration()
.LoadAssemblyFrom(typeof(Test).Assembly.Location)
.LoadAssemblyFrom(typeof(ITest).Assembly.Location)
.ApplyAutoRegistration();
这是我的第一个问题。
This is my first question.
我不知道我是否已经使用了LoadAssemblyFrom方法正确位置:
I'm not sure whether I have used the LoadAssemblyFrom method correctly here:
ITest test = container.Resolve<ITest>();
当我尝试编译我得到的异常ResolutionFailedException。
When I try to compile I get the exception "ResolutionFailedException".
我是什么做错了吗?
感谢您的时间提前。
推荐答案
看来,你正在寻找的是这样的:
It appears that what you are looking for is this:
container.ConfigureAutoRegistration()
.LoadAssemblyFrom(typeof(ITest).Assembly.Location)
.LoadAssemblyFrom(typeof(Test).Assembly.Location)
.Include(If.ImplementsITypeName, Then.Register())
.ApplyAutoRegistration();
这将告诉Unity.AutoRegistration注册各类哪里有同名的,pfixed与我$ P $的接口。
This will tell Unity.AutoRegistration to register all types where there is an interface with the same name, prefixed with I.
相关推荐
最新文章