如何确定 StructureMap 是否多次加载同一个注册表? [英] How can I determine if StructureMap has loaded the same Registry multiple times?

查看:33
本文介绍了如何确定 StructureMap 是否多次加载同一个注册表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在诊断一个似乎与 StructureMap 和注册表有关的问题.我们的一个大型应用程序正在加载注册表,但遇到了一些有趣的副作用.

We are diagnosing an issue which seems to be related to StructureMap and a Registry. A large application of ours is loading a registry, but is experiencing some interesting side-effects.

在没有深入研究所有细节的情况下,我们看到了可以通过将相同的注册表两次添加到 StructureMap 来重现的问题.我们的假设是我们的应用程序也在做同样的事情,可能添加一个实例作为扫描的一部分,第二个实例作为显式注册.

Without going into all the details, we are seeing issues which we can reproduce by adding the same registry to StructureMap twice. Our assumption is that our application is doing the same, perhaps adding one instance as part of a scan and a second as an explicit registration.

如何确定 StructureMap 是否加载了此注册表的多个/重复实例?

How can I determine if StructureMap has loaded multiple/duplicate instances of this registry?

推荐答案

我会跑:

container.WhatDoIHave();

并检查其输出.如果您看到多个对象注册,那么您就知道有问题.

and check its output. If you see multiple registrations for object then you know you have a problem.

或者将日志代码添加到注册表中以查看其是否被多次调用.

Alternatively add logging code to the registry to see if its being called multiple times.

这篇关于如何确定 StructureMap 是否多次加载同一个注册表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆