Ninject + MVC3 = InvalidOperationException: Sequence contains no elements

前端 未结 7 877
借酒劲吻你
借酒劲吻你 2020-12-04 18:37

I created a new MVC3 project, hit F5, saw the sample page.

Then I used NuGet to get the Ninject.MVC extension. I modified my global.asax according to the Ninject doc

7条回答
  •  北海茫月
    2020-12-04 19:20

    You might notice that after installing the ninject.mvc3 NuGet there is an App_Start subfolder created inside your project containing an NinjectMVC3.cs file. Delete this folder and try again. So here are the steps I followed:

    1. Create a new ASP.NET MVC 3 project using the default template
    2. Bring up the Package Manager Console window (View -> Other Windows -> Package Manager Console)
    3. Type install-package ninject.mvc3 on the command line
    4. Replace the default code in Global.asax with the code in your question
    5. Delete the AppStart subfolder created during the installation of the package
    6. Run the application
    7. Enjoy the beauty of the /Home/Index default page opened in your Google Chrome web browser :-)

提交回复
热议问题