可怕的“在扫描的程序集中找不到端点配置” NServiceBus错误

发布于 2024-11-08 22:33:13 字数 1057 浏览 0 评论 0原文

背景:

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

一个订阅者项目运行良好,但另一个订阅者项目失败并出现以下错误:

未处理的异常: System.InvalidOperationException:在扫描的程序集中找不到端点配置。当 NServiceBus 无法加载包含 IConfigureThisEndpoint 的程序集时,通常会发生这种情况。尝试使用 appsetting 键在 NServiceBus.Host.exe.config 中显式指定类型:EndpointConfigurationTypeScanned 路径:此处为我的路径 在 NServiceBus.Host.Program.ValidateEndpoints(IEnumerable`1 端点配置类型) 在 NServiceBus.Host.Program.GetEndpointConfigurationType() at NServiceBus.Host.Program.Main(String[] args)

我怀疑问题一定在于订阅者的 NServiceBus 发布者消息 DLL 无法启动。但是,我不确定如何找出其中的问题。我查看过:

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

我在这里快要疯了,为了让它工作,我已经花了将近一天的时间。任何帮助将不胜感激。

Background:

  • I have two NServiceBus endpoint projects in my solution.
  • Both are NServiceBus subscribers and contain a message handler to one message.
  • Each subscriber project handles a message from one of two different publishers. As such, one project references a messages DLL from one publisher, and the other references a messages DLL from the other publisher.
  • Both publishers are external to my solution.
  • Apart from the messages DLLs, both subscriber projects reference the same binaries for NServiceBus, and additionally have the exact same setup (UnicastBusConfig, EndpointConfig, appSettings, etc)

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

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)

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:

  • both the NServiceBus publishers messages DLL's manifests using ildasm and they are identical (with regards to processor flags and NServiceBus DLL versions referenced).
  • the NSB messages projects, which were both built with .Net 3.5 Framework.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

时间你老了 2024-11-15 22:33:13

好吧,这个例外准确地告诉了你它的含义。
它正在寻找一些实现IConfigureThisEndpoint的类。

我想到三件事:

  • 你忘记实现它(看看 NServiceBus 示例)
  • 你实现了它,但你的类不是 publicinternal
  • 您的文件夹或子文件夹中有多个程序集您的文件位于实现 IConfigureThisEndpoint
  • 程序集和 NServiceBus 程序集的框架版本之间不匹配,即您使用的是为 .NET 3.5 编译的 NServiceBus,但 Visual Studio 2010 创建了您的端点(默认情况下)为.NET 4.0。 (由 David Boike 添加的点)
  • 失败订阅者引用的消息 DLL 是延迟签名的。这导致它失败并出现“未找到端点配置...”错误。在本地构建消息 DLL 的强命名版本可以解决该问题。 (由 thecolour 添加的点)
  • “无端点配置...”异常似乎是由于许多不同的原因而引发的,并且它掩盖了实际原因。该异常基本上只是说找不到配置,它没有说明问题的原始原因是什么。 (由 thecolour 添加的点)
  • 我们使用的 NServiceBus 版本不是针对 .NET v4 编译的。因此,我们需要创建一个配置文件NServiceBus.Host.exe.config来配置要使用的.NET版本。
    • 不要忘记将前面提到的 NServiceBus.Host.exe.config 文件设置为复制到属性窗口中的 /bin/Debug 文件夹中。我经常遇到这种情况……;-)

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

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

我认为似乎抛出了“无端点配置...”异常由于许多不同的原因,它掩盖了真正的原因。有人知道诊断此类问题的好方法吗?

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

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

[编辑]

编辑以添加此线程中其他作者的附加项目以确保完整性。

[编辑2]

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

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

Three things come to my mind:

  • 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... ;-)

The NServiceBus.Host.exe.config file should look like this:

<?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?

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...

[Edit]

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

[EDIT 2]

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

始终不够 2024-11-15 22:33:13

就我而言,我遇到了此异常,因为我使用了 NServiceBus 安装路径中的 NServiceBus.Host.exe 。将其更改为 bin/debug 副本(在两种情况下:服务器和客户端)后,程序可以正确启动。
项目属性->调试->启动外部程序-> bin/debug 文件夹中 NServiceBus.Host.exe 的完整路径

In my case I've got this exception because I've used NServiceBus.Host.exe from NServiceBus install path. After changed it to bin/debug copy (in both cases: server and client), program is starting correct.
Project property -> Debug -> Start external program -> full path to NServiceBus.Host.exe in bin/debug folder

沉睡月亮 2024-11-15 22:33:13

好吧,真正的掌心时刻 - 失败订阅者引用的消息 DLL 仅是延迟签名的。这导致它失败并出现“未找到端点配置...”错误。一旦我在本地构建了消息 DLL 的强命名版本,它就解决了问题。

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

OK a real face-palm moment - The messages DLL the failing subscriber was referencing was delay-signed only. This was causing it to fail with the "No endpoint configuration found..." error. Once I built a strong named version of the messages DLL locally it solved the problem.

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?

苹果你个爱泡泡 2024-11-15 22:33:13

当项目的构建属性设置为在 x86 平台目标上运行时,我也看到了类似的情况。

我最初使用控制台应用程序的输出类型设置该项目,这导致它是使用 x86 的平台目标创建的。

后来我将项目类型更改为类库(但未能将平台类型更改为“任何CPU”)。

将平台目标更改为 Any CPU 使其开始工作。

I've also seen something similar when the build properties of the project were set to run on a platform target of x86.

I originally set the project up with an Output type of Console Application which caused it to be created with a platform target of x86.

I later changed the project type to be a Class Library (but failed to change the platform type to "Any CPU").

Changing the platform target to Any CPU made it start working.

感情旳空白 2024-11-15 22:33:13

发现了可能导致此异常的其他情况,该情况当前未包含在接受的答案中。它特定于使用 Azure 作为 NServiceBus 传输/持久机制。

Azure SDK 未正确安装时,我们也会出现此错误。(这是怎么发生的?如果您获取的是最新版本的 SDK,则平台安装程序效果很好,否则安装的是单独的 SDK 组件可能会导致组件丢失。)

深入了解详细信息:Fusion Log 表明 NServiceBus.Host.exe 无法解析 Microsoft.WindowsAzure.ServiceRuntime。

解决方案是安装以下所有组件(甚至需要模拟器才能解决所有依赖项):

  • WindowsAzureStorageTools.msi
  • WindowsAzureEmulator-x64.exe
  • WindowsAzureTools.vs120.exe
  • -x64.msi
  • WindowsAzureLibsForNet-x64.msi

WindowsAzureAuthoringTools 对于我们的特殊情况,我们必须从以下位置获取 2.3 版本的 sdk:http://www.microsoft.com/en-US/download/details .aspx?id=42317

希望此信息对某人有所帮助。

Found an additional scenario that could result in this exception that is not currently included in the accepted answer. It is specific to using Azure as the NServiceBus transport/persistence mechanism.

This error has also occurred for us when the Azure SDK is not properly installed. (How does that happen? The platform installer works great if you're getting the latest version of the SDK, but otherwise installing the SDK components individually can result in missed components.)

Digging into details: Fusion Log indicated that NServiceBus.Host.exe couldn't resolve Microsoft.WindowsAzure.ServiceRuntime.

The solution was to install all of the following components (even the emulator was needed in order to get all the dependencies resolved):

  • WindowsAzureStorageTools.msi
  • WindowsAzureEmulator-x64.exe
  • WindowsAzureTools.vs120.exe
  • WindowsAzureAuthoringTools-x64.msi
  • WindowsAzureLibsForNet-x64.msi

In our paricular case, we had to get the 2.3 version of the sdk from: http://www.microsoft.com/en-US/download/details.aspx?id=42317

Hope this information helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文