可怕的“在扫描的程序集中找不到端点配置"NServiceBus 错误 [英] The dreaded "No endpoint configuration found in scanned assemblies" NServiceBus error

查看:69
本文介绍了可怕的“在扫描的程序集中找不到端点配置"NServiceBus 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

  • 我的解决方案中有两个 NServiceBus 端点项目.
  • 两者都是 NServiceBus 订阅者,并且都包含一条消息的消息处理程序.
  • 每个订阅者项目都处理来自两个不同发布者之一的消息.因此,一个项目引用来自一个发布者的消息 DLL,而另一个项目引用来自另一发布者的消息 DLL.
  • 两个发布商都在我的解决方案之外.
  • 除了消息 DLL 之外,两个订阅者项目都为 NServiceBus 引用了相同的二进制文件,并且还具有完全相同的设置(UnicastBusConfig、EndpointConfig、appSettings 等)

一个订阅者项目运行良好,但另一个因此错误而失败:

One subscriber project runs fine, but the other one fails with this error:

未处理的异常:System.InvalidOperationException:在扫描的程序集中找不到端点配置.这通常发生在 NServiceBus 无法加载包含 IConfigureThisEndpoint 的程序集时.尝试使用 appsetting 键在 NServiceBus.Host.exe.config 中明确指定类型: EndpointConfigurationTypeScanned path: my path here在 NServiceBus.Host.Program.ValidateEndpoints(IEnumerable`1 endpointConfigurationTypes)在 NServiceBus.Host.Program.GetEndpointConfigurationType()在 NServiceBus.Host.Program.Main(String[] args)

Unhandled Exception: System.InvalidOperationException: No endpoint configuration found in scanned assemblies. This usually happens when NServiceBus fails to load your assembly contaning IConfigureThisEndpoint. Try specifying the type explicitly in the NServiceBus.Host.exe.config using the appsetting key: EndpointConfigurationTypeScanned path: my path here at NServiceBus.Host.Program.ValidateEndpoints(IEnumerable`1 endpointConfigurationTypes) at NServiceBus.Host.Program.GetEndpointConfigurationType() at NServiceBus.Host.Program.Main(String[] args)

我怀疑问题一定在于无法启动的订阅者的 NServiceBus 发布者消息 DLL.然而,我不知道如何解决这个问题.我看过:

My suspicion is that the problem must lie with the NServiceBus publisher messages DLL of the subscriber which is failing to start up. Howerver, I am not sure how to work out what is wrong with this. I have looked at:

  • 两个 NServiceBus 发布者都使用 ildasm 向 DLL 的清单发送消息,并且它们是相同的(关于处理器标志和引用的 NServiceBus DLL 版本).
  • NSB 消息项目,均使用 .Net 3.5 框架构建.

我快要疯了,我花了将近一天的时间试图让它发挥作用.任何帮助将不胜感激.

I am going insane here and have burned almost a day trying to get this working. Any help would be massively appreciated.

推荐答案

好吧,异常会准确地告诉您它是关于什么的.它正在寻找一些实现 IConfigureThisEndpoint 的类.

Well, the exception tells you exactly what it is about. It is looking for some class that implements IConfigureThisEndpoint.

我想到了三件事:

  • 您忘记实现它(查看 NServiceBus 示例)
  • 您实施了它,但您的课程不是公开内部
  • 您的文件所在的文件夹或子文件夹中有多个程序集IConfigureThisEndpoint
  • 您的程序集和 NServiceBus 程序集的框架版本不匹配,即您使用的是为 .NET 3.5 编译的 NServiceBus,但 Visual Studio 2010 将您的端点(默认情况下)创建为 .NET 4.0.(由 David Boike 补充)
  • 失败订阅者引用的消息 DLL 是延迟签名的.这导致它因未找到端点配置..."错误而失败.在本地构建消息 DLL 的强命名版本解决了该问题.(thecolour 添加的点)
  • No endpoint config..."异常似乎有很多不同的原因,它掩盖了实际原因.异常基本上只说找不到配置,并没有说明问题的根源是什么.(thecolour 添加的点)
  • 我们使用的 NServiceBus 版本不是针对 .NET v4 编译的.因此,我们需要创建一个配置文件 NServiceBus.Host.exe.config 来配置要使用的 .NET 版本.
    • 不要忘记将上述 NServiceBus.Host.exe.config 文件设置为复制到属性窗口中的/bin/Debug 文件夹中.一直发生在我身上...... ;-)
    • You forgot to implement it (have a look at the NServiceBus samples)
    • You implemented it but your class is not public or internal
    • You have more than one assembly in the folder or subfolder in which your files are located that implement IConfigureThisEndpoint
    • You have a mismatch between the framework versions of your assemblies and the NServiceBus assemblies, i.e. you're using NServiceBus compiled for .NET 3.5 but Visual Studio 2010 created your endpoint (by default) as .NET 4.0. (point added by David Boike)
    • The messages DLL the failing subscriber is referencing is delay-signed. This is causing it to fail with the "No endpoint configuration found..." error. Build a strong named version of the messages DLL locally solves the problem. (point added by thecolour)
    • The "No endpoint config..." exception seems to be thrown for lots of different reasons, and it kind of masks the actual reason. The exception basically only says that the configuration could not befound, it does not specify what is the original cause of the problem. (point added by thecolour)
    • The NServiceBus version that we use is not compiled against .NET v4. So we need to create a config file NServiceBus.Host.exe.config that configures the .NET version to be used.
      • Do not forget to set the afore mentioned NServiceBus.Host.exe.config file to be copied into the /bin/Debug folder in the properties windows. Happens to me all the time... ;-)

      NServiceBus.Host.exe.config 文件应如下所示:

      <?xml version="1.0" encoding="utf-8"?>
      <configuration>
         <startup>
            <supportedRuntime version="v4.0" />
         </startup>
         <runtime>
             <loadFromRemoteSources enabled="true" />
          </runtime>
      </configuration>
      

      我认为无端点配置..."异常似乎是由于许多不同的原因而引发的,它掩盖了实际原因.有人知道诊断这类问题的好方法吗?

      I think that the "No endpoint config..." exception seems to be thrown for lots of different reasons, and it kind of masks the actual reason. Anyone know a nice way of diagnosing these kind of problems?

      最后一点也发生在我身上.它发生在重命名我的程序集而不是清理项目目录之后.然后 NServiceBus 遍历所有文件,找到旧命名的程序集和新命名的程序集,并以相同的异常结束.

      The last point happend to me, too. It happended after renaming my assembly and not cleaning the project directory. NServiceBus then ran through all files and found both the old named assembly AND the new named assembly and ended with the same exception.

      请注意,如果包含相同接口实现的第二个程序集位于子文件夹内可能会导致错误,也会发生这种情况.这种行为让我在调试时遇到了一些麻烦,因为我之前曾将我的文件复制到一个子文件夹中作为短期备份...

      Please note that this also happens if the second assembly containing the same interface implementation may cause tis error if it is located inside a subfolder. This behaviour had caused me some debugging headaches as I previously had copied my file to a subfolder as a short term backup...

      为了完整起见,已编辑添加此线程中其他作者的其他项目.

      Edited to add the additional items by the other authors in this thread for completeness.

      添加了有关 NServiceBus.Host.exe.config 的更多信息.

      Added more information about NServiceBus.Host.exe.config.

      这篇关于可怕的“在扫描的程序集中找不到端点配置"NServiceBus 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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