Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. .Sln
  2. |- Core
  3. |- Web
  4.  
  5. public class Scheduler
  6. {
  7. public void HangfireIoc()
  8. {
  9. BackgroundJob.Enqueue<MovieSaver>(x => x.SaveMovies());
  10. }
  11. }
  12.  
  13. public class MovieSaver
  14. {
  15. public IMovieApi Api { get; set; }
  16.  
  17. public MovieSaver(IMovieApi api)
  18. {
  19. Api = api;
  20. }
  21. //Other methods
  22. }
  23.  
  24. public void Configuration(IAppBuilder app)
  25. {
  26. var kernal = new StandardKernel();
  27. GlobalConfiguration.Configuration.UseNinjectActivator(kernal);
  28.  
  29. app.UseHangfireDashboard();
  30. app.UseHangfireServer();
  31. }
  32.  
  33. public class Bindings : NinjectModule
  34. {
  35. public override void Load()
  36. {
  37. Bind<IMovieApi>().To<MovieApi>();
  38. }
  39. }
  40.  
  41. Ninject.ActivationException
  42.  
  43. Error activating IMovieApi No matching bindings are available, and the type is not self-bindable.
  44. Activation path: 2) Injection of dependency IMovieApi into parameter api of constructor of type MovieSaver
  45. 1) Request for MovieSaver Suggestions: 1) Ensure that you have defined a binding for IMovieApi.
  46. 2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.
  47. 3) Ensure you have not accidentally created more than one kernel.
  48. 4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name.
  49. 5) If you are using automatic module loading, ensure the search path and filters are correct.
  50.  
  51. kernel.Load<Bindings>();
  52.  
  53. kernel.Load(someAssembly);
  54.  
  55. kernel.Load(typeof(Startup).Assembly);
  56.  
  57. ConfigureAuth(app);
  58.  
  59. GlobalConfiguration.Configuration
  60. .UseSqlServerStorage("ConnectString");
  61.  
  62. GlobalConfiguration.Configuration.UseNinjectActivator(new Ninject.Web.Common.Bootstrapper().Kernel);
  63.  
  64.  
  65. app.UseHangfireDashboard();
  66. app.UseHangfireServer();
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement