We have a large solution, and one particular project that seems to cause problems. This project ("Woti.Xift.Core") contains many common types, and so is taken as a dependency (directly or indirectly) by most other projects in the solution. It seems that whenever this project is modified, the tests that depend on it fail, throwing a System.IO.FileLoadException. Here is a representative stack trace:
Quote:System.IO.FileLoadException : Could not load file or assembly 'WOTI.Xift.Core, Version=5.10.0.14171, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
at Castle.Proxies.Invocations.IScribeFormService_GetFormViewModel.InvokeMethodOnTarget()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Xift.Infrastructure.Aop.UnitOfWorkInterceptor.TryInvokeMethod(IInvocation invocation, String targetDatabaseName, Boolean isQuery, Boolean isReadonlyOperation) in C:\Xift\Libraries\Infrastructure\Aop\UnitOfWorkInterceptor.cs:line 210
at Xift.Infrastructure.Aop.UnitOfWorkInterceptor.Intercept(IInvocation invocation) in C:\Xift\Libraries\Infrastructure\Aop\UnitOfWorkInterceptor.cs:line 83
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.IScribeFormServiceProxy.GetFormViewModel(FormViewParams param)
at Scribe.IntegrationTests.ScribeFormServiceTests.FormViewModelIsCorrect() in C:\Xift\Tests\Scribe.IntegrationTests\ScribeFormServiceTests.cs:line 67
The only way to resolve this is to do something that forces a rebuild and reload of Woti.Xift.Core, e.g. restart the NCrunch engine, reload and rebuild Woti.Xift.Core, etc. This is really annoying, as either one of these options essentially requires a rebuild of every single project.
This error only occurs in the context of running tests in NCrunch, and no where else in our system.
A little background: we use AOP (method intercepters) using Autofac, which in turn uses Castle.DynamicProxy. Autofac, at runtime, creates a proxy for our intercepted object, calls the interception logic, then invokes the actual method on our actual object. It's at this point where the failure seems to happen.
My best guess as to what's going on is that there's some sort of conflict as to which version of the Core assembly should be used. I can confirm that the above test project references both Core, as well as many dependencies that themselves reference Core. Here's a mock-up of the dependency graph (sorry, whitespace isn't being preserved, so it might not be as clear as I'd like).
Test Project ---> Core
|
---->web app project -----> "Infrastructure" project -----> Autofac
| |
| ------> Castle.Core
| |
| ------> Core
|
-------> X ------> Core
|
-------> Y -------> Z ------->Core
I'm looking for any solution available to make this problem go away.