0

我正在尝试使用 StructureMap 2.6.4 扫描一个模块文件夹(dll,运行时已知的位置),以查找任何关闭某个接口的模块。在本例中,它是来自 MassTransit 的 Consumes.Context。

我的类,其中可能有许多实现,在模块文件夹中:

    public class MyConsumer : Consumes<MyMessage>.Context
    {

        public void Consume(IConsumeContext< MyMessage > message)
        {
            // Do some stuff

            message.Respond(response);
        }
    }

我的 StructureMap 扫描仪:

        container.Configure(x => x.Scan(y =>
        {
            y.TheCallingAssembly();
            y.WithDefaultConventions();
            y.LookForRegistries();
            y.ConnectImplementationsToTypesClosing(typeof(Consumes<>.Context));
            y.AddAllTypesOf(typeof(Consumes<>.Context));
            y.AssembliesFromPath(@"..\..\..\Web\Modules\bin\debug");         
        }));

当我查看容器中的对象时,我没有看到我的任何 Consumes<>.Context 实现。我确实在调试文件夹中看到了来自其他 dll 的对象。

但是,如果我将模块的 dll 复制到子目录并像这样扫描:

y.AssembliesFromPath(@"..\..\..\Web\Modules\bin\debug\test")

扫描仪捡起我的物品。

失败:

y.AssembliesFromPath(@"..\..\..\Web\Modules\bin\debug");

作品:

y.AssembliesFromPath(@"..\..\..\Web\Modules\bin\debug\test");

为什么将我的 dll 放在子目录中工作而不在父目录中工作?

我应该如何在 Modules 目录中扫描 Consumes.Context 的实现?谢谢!

4

0 回答 0