hangfireio / hangfire.ninject Goto Github PK
View Code? Open in Web Editor NEWHangfire job activator based on Ninject IoC Container
License: MIT License
Hangfire job activator based on Ninject IoC Container
License: MIT License
I configured thisn in Startup.Configuration method of my Web Application .NET 4.8 but keep receiving a System.MissingMethodException complaining about a not existing "parameterless constructor defined".
var kernel = new StandardKernel();
kernel.Bind<MessageTasks>().ToSelf();
kernel.Bind<IMessageRepository>().ToMethod(ctx => new MessageRepository(OracleConnectionFactory.CreateContext()));
GlobalConfiguration.Configuration.UseNinjectActivator(kernel);
What did I missed?
Packages:
Hangfire.AspNet (0.2.0)
Hangfire.Core (1.7.9)
Hangfire.Ninject (1.2.0)
Ninject (3.2.2)
Ninjec.Web.Common (3.2.0)
Currently the following method is used to dispose all the requested services, when background job is completed. This method gracefully handles transient dependencies, but it also disposes singleton services that implement the IDisposable
interface.
public override void DisposeScope()
{
_kernel.Components.Get<ICache>().Clear(JobActivatorScope.Current);
}
It's worth to read this article to know how to correctly implement deterministic disposal with Ninject: http://mono.software/2016/04/21/Ninject-ambient-scope-and-deterministic-dispose/
Hi,
We found an issue when using the "InBackgroundScope" option. If you include async methods in the process, as the scope is stored in the thread, it gets lost in inner methods. We solved it by using AsyncLocal feature from .NET 4.6 to store the current scope (by modifying the source code of this library). That way, any resolution that happens inside the job scope gets the same instances.
I think it would be an interesting addition to this library or a change in the Hangfire core itself, but the problem is backward compatibility to previous framework versions.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.