Unity 忽略 app.config 中的类型映射
我的 app.config 的相应部分中有以下设置:
<alias alias="resourceManager"
type="Infrastructure.Dictionary.Localization.IResourceManager, Infrastructure.Dictionary" />
<register type="resourceManager"
mapTo="Infrastructure.Dictionary.Localization.LocalizeDictionaryWrapper, Infrastructure.Dictionary"
name="Default">
<lifetime type="singleton" />
</register>
当我调用 container.Resolve(NonLocalizedStrings.Default); 时
我得到以下异常:
“依赖关系解析失败,类型 = “Infrastructural.Dictionary.Localization.IResourceManager”,名称= “默认”。异常发生时: while 解决。 例外是:InvalidOperationException - 当前 类型 Infrastructure.Dictionary.Localization.IResourceManager 是一个 接口,无法构造。您是否缺少类型 映射? 异常发生时,容器是: 解析Infrastruction.Dictionary.Localization.IResourceManager,默认”
为什么 Unity 会忽略我的映射?
I have the following settings in the appropriate sections of my app.config:
<alias alias="resourceManager"
type="Infrastructure.Dictionary.Localization.IResourceManager, Infrastructure.Dictionary" />
<register type="resourceManager"
mapTo="Infrastructure.Dictionary.Localization.LocalizeDictionaryWrapper, Infrastructure.Dictionary"
name="Default">
<lifetime type="singleton" />
</register>
When I call container.Resolve(NonLocalizedStrings.Default);
I get the following exception:
"Resolution of the dependency failed, type =
"Infrastructure.Dictionary.Localization.IResourceManager", name =
"Default".Exception occurred while: while
resolving.
Exception is: InvalidOperationException - The current
type, Infrastructure.Dictionary.Localization.IResourceManager, is an
interface and cannot be constructed. Are you missing a type
mapping?
At the time of the exception, the container was:
Resolving Infrastructure.Dictionary.Localization.IResourceManager,Default"
Why is Unity ignoring my mapping?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的不好。我试图在 Unity 有机会配置其容器之前解析类型。
My bad. I am attempting to resolve a type before Unity has had the chance to configure its container.