0

我的 Global.asax.cs 中有以下内容:

using System.Web.Mvc;
using System.Web.Routing;
using HandiGamer.WebUI.ConditionalValidation;
using HandiGamer.Domain.Concrete;
using Ninject;
using Ninject.Web.Common;
using System.Reflection;
using HandiGamer.Domain.Abstract; 

//namespace....

public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("favicon.ico");

        routes.MapRoute(
            null,
            "Reviews/{id}",
            new { controller = "Reviews", action = "ShowReviewById" },
            new { id = @"\d+" }
        );

        routes.MapRoute(
            null,
            "Reviews/Latest",
            new { controller = "Reviews", action = "Latest"}
        );

        routes.MapRoute(
            null,
            "Reviews/{slug}",
            new { controller = "Reviews", action = "ShowReviewBySlug" },
            new { slug = @"[0-9a-zA-Z\-]+" }
        );

        routes.MapRoute(
            null,
            "News/{id}",
            new { controller = "News", action = "ShowNewsById" },
            new { id = @"\d+" }
        );

        routes.MapRoute(
            null,
            "News/{slug}",
            new { controller = "News", action = "ShowNewsBySlug" },
            new { slug = @"[0-9a-zA-Z\-]" }
        );

        routes.MapRoute(
            null,
            "Articles/{id}",
            new { controller = "Articles", action = "ShowArticleById" },
            new { id = @"\d+" }
        );

        routes.MapRoute(
            null,
            "Articles/{slug}",
            new { controller = "Articles", action = "ShowArticleBySlug" },
            new { slug = @"[0-9a-zA-Z\-]" }
        );

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

        routes.MapRoute(
            null,
            "{*path}",
            new { controller = "Error", action = "Http404" }
        );
    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);
        DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
        DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredIfAttribute), typeof(RequiredIfValidator));
    }

    protected override IKernel CreateKernel()
    {
        var kernel = new StandardKernel();
        kernel.Bind<IArticleRepository>().To<HGArticleRepository>();
        kernel.Bind<IGameRepository>().To<HGGameRepository>();
        kernel.Bind<INewsRepository>().To<HGNewsRepository>();
        kernel.Load(Assembly.GetExecutingAssembly());
        return kernel;
    }
}

但是在构建我的解决方案时,我收到以下错误:

Error 1 'HandiGamer.MvcApplication.CreateKernel()': no suitable method found to override C:\Users\Kevin\documents\visual studio 2010\Projects\HandiGamer\HandiGamer\Global.asax.cs 92 36 HandiGamer.WebUI

有任何想法吗?我几乎复制了 github 示例应用程序中的内容,所以我很难过。

4

1 回答 1

1

您必须从 NinjectHttpAplication 派生

于 2012-05-06T00:53:33.420 回答