可怕的“在扫描的程序集中找不到端点配置” NServiceBus错误
背景:
- 我的解决方案中有两个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,这个例外准确地告诉了你它的含义。
它正在寻找一些实现IConfigureThisEndpoint的类。
我想到三件事:
NServiceBus.Host.exe.config 文件应该如下所示:
我认为似乎抛出了“无端点配置...”异常由于许多不同的原因,它掩盖了真正的原因。有人知道诊断此类问题的好方法吗?
最后一点也发生在我身上。这是在重命名我的程序集并且没有清理项目目录后发生的。
然后,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:
The NServiceBus.Host.exe.config file should look like this:
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
.就我而言,我遇到了此异常,因为我使用了 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
好吧,真正的掌心时刻 - 失败订阅者引用的消息 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?
当项目的构建属性设置为在 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.
发现了可能导致此异常的其他情况,该情况当前未包含在接受的答案中。它特定于使用 Azure 作为 NServiceBus 传输/持久机制。
当 Azure SDK 未正确安装时,我们也会出现此错误。(这是怎么发生的?如果您获取的是最新版本的 SDK,则平台安装程序效果很好,否则安装的是单独的 SDK 组件可能会导致组件丢失。)
深入了解详细信息:Fusion Log 表明 NServiceBus.Host.exe 无法解析 Microsoft.WindowsAzure.ServiceRuntime。
解决方案是安装以下所有组件(甚至需要模拟器才能解决所有依赖项):
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):
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.