【发布时间】:2010-12-20 07:19:09
【问题描述】:
我正在尝试测试一种依赖于 NServiceBus 的方法。这是一个集成测试,所以我使用的是一个真实的 NSB 实例,而不是模拟它。由于原始应用程序使用 WithWeb() 我需要先将其换成不同的启动脚本(请参阅此问题和我的答案: How do I Unit Test NServiceBus.Configure.WithWeb()? )
现在我遇到了一个新问题。该代码在我运行时有效,但在我的测试中它在配置中失败。以下是相关的堆栈信息: 内部异常:System.IO.FileLoadException Message=无法加载文件或程序集 'file:///C:\Dev\Foo\src\IntegrationTests\bin\Debug\Antlr3.Runtime.dll' 或其依赖项之一。不支持操作。 (来自 HRESULT 的异常:0x80131515) 源=mscorlib FileName=file:///C:\Dev\Foo\src\IntegrationTests\bin\Debug\Antlr3.Runtime.dll 融合日志="" 堆栈跟踪: 在 System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串代码库,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark 和 stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔suppressSecurityChecks) 在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,StackCrawlMark 和 stackMark,Boolean for Introspection,Boolean suppressSecurityChecks) 在 System.Reflection.RuntimeAssembly.InternalLoadFrom (字符串 assemblyFile,证据 securityEvidence,Byte [] hashValue,AssemblyHashAlgorithm hashAlgorithm,Boolean for Introspection,Boolean suppressSecurityChecks,StackCrawlMark 和 stackMark) 在 System.Reflection.Assembly.LoadFrom(字符串 assemblyFile) 在 C:\Dev\nservicebus\src\config\NServiceBus.Config\Configure.cs: 233 行中的 NServiceBus.Configure.GetAssembliesInDirectoryWithExtension(String path, String extension, String[] assemblyToSkip) 在 C:\Dev\nservicebus\src\config\NServiceBus.Config\Configure.cs: 219 行中的 NServiceBus.Configure.d__7.MoveNext() 处
如果我在集成测试中添加对 Antlr3.Runtime.dll 的引用,此错误就会消失,并被替换为无法找到 Iesi.Collections... Antlr.Runtime 和 Iesi.Collections 都是其中的一部分NServiceBus.Core.dll,所以没有理由直接在 /bin 路径中查找,而不是从该程序集中加载这些。 NServiceBus、NServiceBus.Core、NServiceBus.ObjectBuilder.StructureMap都被测试项目引用,在测试项目的bin文件夹中。
为什么 NServiceBus 没有在自己的程序集中找到它需要的程序集?
【问题讨论】:
-
您是否尝试在自定义启动中限制扫描的程序集集?例如 Configure.With(Assembly[]).
标签: nservicebus