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 に答える