开发者

Scanning for types with AssembliesFromPath in StructureMap

I'm working on an application where we are using StructureMap 2.5.4 to scan a directory like below.

ObjectFactory.Configure(scanner => scanner.Scan(x =>
{
    x.AssembliesFromPath(settings.Directory);
    x.AddAllTypesOf(typeof(IScannerConvention)).NameBy(n => n.Name);
}));

For some reason the types implementing IScannerConvention are not registered. If w开发者_Python百科e change AddAllTypesOf to typeof(object) we can see that the types we are looking for are registered with the container but that is obviously not what we want to do. We have also tried moving the assemblies containing types implementing IScannerConvention to the application base directory and use x.AssembliesFromApplicationBaseDirectory(). This works and the expected types are registered. But again, this is not a solution that we can use as it will cause conflicts moving all assemblies to the application base directory. At this point I really have no ide on what could be wrong.

Any ideas are most welcome!


Got some help on this matter on the StructureMap google group. You can find the solution here: http://groups.google.com/group/structuremap-users/browse_thread/thread/73ae145b3766bfb1

The problem was that the assembly containing the interface being scanned was loaded twice, since it existed both in the application folder and in another folder. When the assembly copy was removed and no longer loaded, the problem was solved.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜