NServiceBus在扫描时抛出stackoverflow

时间:2014-08-21 16:24:41

标签: nservicebus

当我将消息类型对象移动到另一个程序集时,遇到此问题。出于某种原因,当同一项目中存在消息和处理程序时,我没有遇到任何问题。

NServiceBus在扫描程序集时抛出StackoverflowException。这就是我目前配置NServiceBus的方式:

var bus = NServiceBus.Configure
            .With(AllAssemblies.Matching("Presentation"))
            .DefineEndpointName("Presentation")
            .StructureMapBuilder()
            .Log4Net()
            .DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && t.Namespace.EndsWith("Events"))
            .DefiningCommandsAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && t.Namespace.EndsWith("Commands"))
            .DefiningMessagesAs(t => t.Namespace != null && t.Namespace.StartsWith("Demo") && (t.Namespace.EndsWith("Messages") || t.Namespace.EndsWith("Queries")))
            .UnicastBus()
            .InMemorySubscriptionStorage()
            .UseInMemoryTimeoutPersister()
            .InMemoryFaultManagement()
            .InMemorySagaPersister()
            .CreateBus()
            .Start();

它在NServiceBus.Configure.GetAllowedTypes中溢出,从我可以告诉它扫描我的3个Presentation项目(Presentation,Presentation.Inventory和Presentation.Inventory.Messages)就好了,然后再次运行该方法来扫描NServiceBus。导致溢出的核心。

我目前存在的项目结构如下:https://github.com/volak/DDD.Enterprise.Example

使用NServiceBus 4.6.3

我还发现如果我允许它扫描NServiceBus.Core,结构图的汇编扫描程序会抛出一个堆栈溢出 - 也许这是一个bug?

1 个答案:

答案 0 :(得分:3)

我将此问题追溯到Fody.Costura,特别是此问题https://github.com/Fody/Costura/issues/48

他们建议程序集重定向在不受Costura管理的程序集的不同版本中导致无限循环。 NServiceBus使用Fody很多,所以我尝试删除web.config中的所有程序集重定向,然后启动就好了。

因此,如果您遇到此问题,您可能会引用某个程序集的2个不同版本,则应在删除所有重定向之前修复该问题。

对我来说,问题是Raven.Client.Lightweight和Raven.Abstractions

我在想NServiceBus可能会将这些程序集编织到它的DLL中,我也是从nuget中使用它们