Note that there are some explanatory texts on larger screens.

plurals
  1. PONServiceBus Can't Load Dependent Assemblies Within Unit Test
    text
    copied!<p>I'm trying to test a method that relies on NServiceBus. This is an integration test so I'm working with a real instance of NSB, not mocking it out. Since the original application uses WithWeb() I needed to first swap that out with a different startup script (see this question and my answer here: <a href="https://stackoverflow.com/questions/3752734/how-do-i-unit-test-nservicebus-configure-withweb">How do I Unit Test NServiceBus.Configure.WithWeb()?</a> )</p> <p>Now I've run into a new problem. The code works when I run it, but within my test it is failing in the Configuration. Here is the relevant stack information: InnerException: System.IO.FileLoadException Message=<strong>Could not load file or assembly 'file:///C:\Dev\Foo\src\IntegrationTests\bin\Debug\Antlr3.Runtime.dll' or one of its dependencies</strong>. Operation is not supported. (Exception from HRESULT: 0x80131515) Source=mscorlib <strong>FileName=file:///C:\Dev\Foo\src\IntegrationTests\bin\Debug\Antlr3.Runtime.dll</strong> FusionLog="" StackTrace: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark&amp; stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at NServiceBus.Configure.GetAssembliesInDirectoryWithExtension(String path, String extension, String[] assembliesToSkip) in c:\Dev\nservicebus\src\config\NServiceBus.Config\Configure.cs:line 233 at NServiceBus.Configure.d__7.MoveNext() in c:\Dev\nservicebus\src\config\NServiceBus.Config\Configure.cs:line 219</p> <p>If I add a reference to Antlr3.Runtime.dll to my integration test, this error goes away and is replaced by one saying that it cannot find Iesi.Collections... Both Antlr.Runtime and Iesi.Collections are a part of NServiceBus.Core.dll, so there's no reason why it should be looking in the /bin path directly, rather than loading these from within that assembly. NServiceBus, NServiceBus.Core, and NServiceBus.ObjectBuilder.StructureMap are all referenced by the test project and are in the test project's bin folder.</p> <p>Why is NServiceBus not finding the assemblies it needs that are within its own assembly?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload