3

I am using VS2012 RC and created a MVC4 app in .NET 4.0 mode. I use Ninject + Ninject.MVC3 as a DI container. It works on my development machine on Windows and on another machine with .NET 4.0 installed, but when I deploy it on a Linux server with Mono 3.0.2, XSP and fastcgi + lighttpd I just get a Ninject related error message:

System.InvalidOperationException
Sequence contains no matching element

  at System.Linq.Enumerable.Single[DataAnnotationsModelValidatorProvider] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0 
  at System.Linq.Enumerable.Single[DataAnnotationsModelValidatorProvider] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 
  at Ninject.Web.Mvc.NinjectMvcHttpApplicationPlugin.Start () [0x00000] in <filename unknown>:0 
  at Ninject.Web.Common.Bootstrapper.<Initialize>b__0 (INinjectHttpApplicationPlugin c) [0x00000] in <filename unknown>:0 
  at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[INinjectHttpApplicationPlugin] (IEnumerable`1 series, System.Action`1 action) [0x00000] in <filename unknown>:0 
  at Ninject.Web.Common.Bootstrapper.Initialize (System.Func`1 createKernelCallback) [0x00000] in <filename unknown>:0 
  at MvcApplication1.App_Start.NinjectWebCommon.Start () [0x00000] in <filename unknown>:0 
  at MvcApplication1.MvcApplication.Application_Start () [0x00000] in <filename unknown>:0 

To clarify: I had to manually call the Start and Stop methods of the generated NinjectWebCommon class, because the [assembly: WebActivator.PreApplicationStartMethod...] attribute gets ignored (I first got error messages regarding missing default constructors, which are normal for a DI-ed controller)

I also tried subclassing NinjectHttpApplication, but I got the same error.

Any help here?

dove
  • 20,469
  • 14
  • 82
  • 108
Stefan
  • 141
  • 1
  • 5

1 Answers1

0

DI containers are kind of flaky in Mono in my experience. If you don't have time to dig up deeper and fix what possibly seems to be a Mono bug, I would try a different DI container.

knocte
  • 16,941
  • 11
  • 79
  • 125