ninject/ninject.mockingkernel — Issue #9: Dependency problems getting MockingKernel working
Author: mikebridge
Created: 2011-12-23 17:36:23+00:00
State: open

The MockingKernel looks very promising, but I'm having problems getting a version working with Moq on .Net 4.0----I'm using the Ninject.MockingKernel-2.2.0.0-release-net-4.0.zip download from git but it is has a hard dependency on a particular version of Moq:

System.IO.FileLoadException : Could not load file or assembly 'Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

So I checked the source out from git, and downloaded these to compile with it as per the HowToBuild.txt instructions:

Ninject.Extensions.NamedScope-2.2.0.0-release-net-4.0.zip
Ninject.Extensions.ContextPreservation-2.2.0.0-release-net-4.0.zip
Ninject-2.2.1.0-release-net-4.0.zip

I run UnzipDependencies.cmd but it deletes the version of Ninject.dll in lib (is it supposed to do that?), and indeed when I run ninject I received errors saying Ninject could not be found:

[msbuild] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Ninject". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\Visual Studio 2010\Projects\ninject.mockingkernel\src\Ninject.MockingKernel\Ninject.MockingKernel.csproj]

I opened the project in Visual Studio 2010 and upgraded to .Net 4.0 and fixed the dependencies there, but I'm now getting the following error:

Error	1	'Ninject.Syntax.IBindingToSyntax' does not contain a definition for 'BindingConfiguration' and no extension method 'BindingConfiguration' accepting a first argument of type 'Ninject.Syntax.IBindingToSyntax' could be found (are you missing a using directive or an assembly reference?)	C:\Visual Studio 2010\Projects\ninject.mockingkernel\src\Ninject.MockingKernel\ExtensionsForBindingSyntax.cs	(line 39)

I assume it has a dependency on a different version of Ninject. At that point I started to wonder if recompiling was indeed the best route to go---it looks like something's out of date. Any advice on how to continue?

I'd much rather just download a precompiled version that will not introduce a hard dependency on an old Moq version (I'm using the current-release version of Moq: v4.0.20926).

Thanks!

-Mike