"The sequence does not contain element exceptions when initializing ninject

I have a problem with Ninject that I have not seen before and do not know how to fix. I am using MVC NuGet package for MVC 5.

In my NinjectWebCommon.cs there is the following method:

    public static void Start() 
    {
        DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
        DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
        bootstrapper.Initialize(CreateKernel);
    }

However, when he tries to execute the last line, he crashes, complaining that "the sequence contains no elements." I previously used Unity for DI, but changed it to Ninject.

Any ideas?

Thanks in advance, M

+4
source share
4 answers

In my case, my project had two NinjectWebCommon.cs folders with the same / similar content. Deleting the folder resolved the issue.

+8
source

penneth @Pavan . . DLL, bin. . .

+4

, Entire.

, .

, , " ".

, , , .....

  • , → "

  • Delete the folder "bin" and "obj"

  • Clear entire project

  • Build application

  • and finally run the application.

Hope this works for you ....

Thank...

+3
source

I think this is a hoax for this question: Ninject + MVC3 = InvalidOperationException: The sequence contains no elements

TL DR - make sure that you delete all old DLLs when publishing your site.

+2
source

Source: https://habr.com/ru/post/1548610/


All Articles