ninject/ninject.extensions.factory — Issue #1: this module doesnt seem to be compatible when WCF Extensions or MVC3 extensions are in use
Author: cbertolasio
Created: 2011-12-19 17:30:04+00:00
State: open

I am trying to use the Factory extensions in the same project that uses MVC3 extensions and WCF Extensions. My test is synonymous with the "CustomInstanceProviderTest" in file "src/Ninject.Extensions.Factory.Test/FactoryTests.cs".

I have downloaded all of the latest 2.3 builds from the build server and I am referencing these compiled assemblies in my test project.

When I run my unit tests where ONLY Ninject and the Factory extensions are referenced, then all is well and works as expected. However, when I continue adding the other Extensions and Ninject Dependencies to support WCF and MVC then things start to fail.

This is the error that is output at test time...
"Test 'NinjectFactoryExtension.FactoryTests.TransactionManagerIsCreated' failed: System.MissingMethodException : Method not found: 'Ninject.Syntax.IBindingWhenInNamedWithOrOnSyntax`1 Ninject.Syntax.IBindingToSyntax`1.To()'.
at Ninject.Extensions.Wcf.WcfModule.Load()
at Ninject.Modules.NinjectModule.OnLoad(IKernel kernel)
at Ninject.KernelBase.Load(IEnumerable`1 m)
at Ninject.KernelBase.Load(IEnumerable`1 assemblies)
at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 filenames)
at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns)
at Ninject.KernelBase.Load(IEnumerable`1 filePatterns)
at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules)
at Ninject.KernelBase..ctor(INinjectModule[] modules)
at Ninject.StandardKernel..ctor(INinjectModule[] modules)
Class1.cs(19,0): at NinjectFactoryExtension.FactoryTests.TransactionManagerIsCreated()"

Steps to repro...

Create a unit test project
Add references to the following...
- Ninject 2.3.0.67 (the version that is in the lib folder with Ninject.Extensions.Factory)
- Ninject.Extensions.Factory 2.3.0.11
- Ninject.Extensions.WCF 2.3.0.22
- Ninject.Web.Common 2.3.0.18

There is an alternate scenario, that produces another error. When you add a reference to Ninject.Web.MVC from build artifact "Ninject.Web.Mvc3-2.3.0.18-release-net-4.0" then you end up with the following error:

"Test 'NinjectFactoryExtension.FactoryTests.TransactionManagerIsCreated' failed: System.TypeLoadException : Could not load type 'Ninject.Infrastructure.IHaveBindingConfiguration' from assembly 'Ninject, Version=2.3.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7'.
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at Ninject.Infrastructure.Language.ExtensionsForAssembly.HasNinjectModules(Assembly assembly)
at Ninject.Modules.CompiledModuleLoaderPlugin.b__0(Assembly asm)
at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
at Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 filenames)
at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns)
at Ninject.KernelBase.Load(IEnumerable`1 filePatterns)
at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules)
at Ninject.KernelBase..ctor(INinjectModule[] modules)
at Ninject.StandardKernel..ctor(INinjectModule[] modules)
Class1.cs(19,0): at NinjectFactoryExtension.FactoryTests.TransactionManagerIsCreated()"