I got this error when using Ninject with Web API.
public static class NinjectWebCommon
{
private static readonly Bootstrapper bootstrapper = new Bootstrapper();
/// <summary>
/// Starts the application
/// </summary>
public static void Start()
{
try
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
bootstrapper.Initialize(CreateKernel1);
}
catch (Exception ex)
{
WriteLog(ex.Message +"-------------------------------"+ ex.Source +"---" +ex);
throw;
}
}
/// <summary>
/// Stops the application.
/// </summary>
public static void Stop()
{
bootstrapper.ShutDown();
}
/// <summary>
/// Creates the kernel that will manage your application.
/// </summary>
/// <returns>The created kernel.</returns>
private static IKernel CreateKernel1()
{
WriteLog("CreateKernel1 -- 5");
var kernel = new StandardKernel();
try
{
WriteLog("CreateKernel1 -- 6");
kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
NinjectServiceRegister ser = new NinjectServiceRegister(kernel);
ser.RegisterServices();
AutoMapperConfig autoMapperConfig = new AutoMapperConfig(kernel);
autoMapperConfig.RegisterServices();
WriteLog("CreateKernel1 -- 7");
kernel.BindHttpFilter<ApiAuthneticatonFilter>(System.Web.Http.Filters.FilterScope.Global).WhenControllerHas<CollectorsAuthenticationAttribute>();
kernel.BindHttpFilter<CollectorsAuthorizationFilter>(System.Web.Http.Filters.FilterScope.Global).WhenControllerHas<CollectorsAuthroizationAttribute>();
WriteLog("CreateKernel1 -- 8");
System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new Ninject.Web.WebApi.NinjectDependencyResolver(kernel);
return kernel;
}
catch(Exception ex)
{
WriteLog("Authenticate -- 9" + ex.Message);
kernel.Dispose();
throw;
}
}
error message:
-CollectorsApp.MobileWebAPI---System.TypeLoadException: Method 'ExecuteAuthorizationFilterAsync' in type 'CollectorsApp.MobileWebAPI.InfraStructure.Authorization.CollectorsAuthorizationFilter' from assembly 'CollectorsApp.MobileWebAPI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at CollectorsApp.MobileWebAPI.App_Start.NinjectWebCommon.CreateKernel1() at Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) at CollectorsApp.MobileWebAPI.App_Start.NinjectWebCommon.Start() in D:\IGATE\InvogateWeb-Siva\InvogateWeb\CollectorsApp.MobileWebAPI\App_Start\NinjectWebCommon.cs:line 34