GlobalConfiguration.Configuration.UseNinjectActivator does not exist with Hangfire.Ninject - ninject

I have been using Ninject and Hangfire for a while and just added the Ninject.Hangfire package. However the following extension method just doesn't seem to be loading despite having updated both all 3 of these packages.

Restarting Visual Studio triggered it to work.
I think it could be because Hangfire and Hangfire.Ninject both use the Hangfire namespace (which is where UseNinjectActivator is defined).
So something just isn't refreshing.

Related

Ninject Kernel being disposed on startup after updating Microsoft.AspNet.Identity.Owin 2.2.0

I am working on a WebApplication which uses MVC5 and WebApi 2 with Owin. I recently updated Microsoft Asp.Net NuGet packages (Microsoft.AspNet.Mvc, etc.) from version 5.2.2 to 5.2.3, and the Owin NuGet packages (Microsoft.Owin, etc.) from 3.0.0 to 3.0.1. I also updated Microsoft.AspNet.Identity.Owin from version 2.1.0 to version 2.2.0
I then updated the corresponding Ninject WebApi packages (Ninject.Web.WebApi, etc.) from 3.2.3 to version 3.2.4 in order to get it to compile, but did not update Ninject.Web.Common.OwinHost, since this was at the latest version (3.2.3).
When I try to run the application, I get the following error:
Error loading Ninject component ICache
No such component has been registered in the kernel's component container.
Suggestions:
1) If you have created a custom subclass for KernelBase, ensure that you have properly implemented the AddComponents() method.
2) Ensure that you have not removed the component from the container via a call to RemoveAll().
3) Ensure you have not accidentally created more than one kernel.
The Kernel that I am creating in the OwinStartup class using is being disposed from the Owin.AppBuilderExtensions.CreateOwinContext() method, which is indirectly from OwinBootstrapper.Execute().
This has only started happening since updating the Asp.Net NuGet packages to 5.2.3. Before updating the packages, OwinBootstrapper.Execute() is still called, but does not cause Owin.AppBuilderExtensions.CreateOwinContext() or KernelBase.Dispose() to be called.
I have not changed any of the code in OwinStartup, and my Ninject Kernel is still being created using:
public virtual void Configuration(IAppBuilder app)
{
app.UseNinjectMiddleware(CreateKernel);
app.CreatePerOwinContext(CreateKernel);
}
I have tried updating the NuGet packages one at a time, and the specific update that causes the issue is Microsoft.AspNet.Identity.Owin to 2.2.0 Are there any known compatibility issues with Ninject and AspNet.Identity.Owin 2.2.0?
This from Hao: I think that should be fine, so long as ninject takes care of disposing the per request objects somehow
By looking at the previous source code and current source code, it looks like they are expecting a IDisposable object and calls it immediately at the end of its life cycle (aka request).
I also noticed that other CreatePerOwinContext they provide when installing OWIN such as app.CreatePerOwinContext(ApplicationDbContext.Create); was never disposed (in 2.1.0)? This seems like a big memory leak as they instantiate some classes every time there is a request.
To go around the problem when using CreatePerOwinContext with Ninject StandardKernel, I tried with the following code:
app.CreatePerOwinContext(
(Microsoft.AspNet.Identity.Owin.IdentityFactoryOptions<IKernel> options, IOwinContext context) => kernel,
(Microsoft.AspNet.Identity.Owin.IdentityFactoryOptions<IKernel> options, IKernel instance) => {}
);
Basically, I do nothing in the dispose callback.
I do not know if this will lead to some memory leak but it definitely makes the app work again.

Field not found: 'Nancy.Bootstrapper.NancyBootstrapperLocator.Bootstrapper'

i recently have been using Nancy fx and i'm in love with it, but when i try to make a structuremap ioc like the documentation page suggested i get the error
Field not found: 'Nancy.Bootstrapper.NancyBootstrapperLocator.Bootstrapper'.
i have override the getApplicationContainer function like shown in the file
https://github.com/CarlosBolanos/apadrina/blob/master/Application/Bootstrapper.cs
but still get the same error, i look on the code on the rnancy repository
https://github.com/NancyFx/Nancy.Bootstrappers.StructureMap/blob/master/src/Nancy.Bootstrappers.StructureMap/StructureMapNancyBootstrapper.cs
and i cant see the bootstrapper property
does any1 else have this error too i've been trying to set this up for hours,
if i remove the nancystructuremap in nugget the error goes away.
or do i need to set something else on the bootstrap class.
I ran into this scenario after installing Nancy.Bootstrappers.Ninject from Nuget. My Nancy project was created using the Nancy Visual Studio templates, and were referencing Nancy 0.21.1.
What I found was installing the bootstrapper package caused the base Nancy package to get upgraded from 0.21.1 to 0.23.2. This is fine, except that the Nancy.Hosting.Aspnet and the Razor engine packages were NOT upgraded from 0.21.1.
To fix the error, I had to update all of the Nancy-related packages I was using to match the 0.23.2 package.

Orchard CMS Extension Manifest could not loaded

I'm trying to make my own calendar widget and module by following a tutorial on youtube and everything works fine until now. I got this kind of error in the Orchard Dashboard
"The extension 'BYUtv.CalendarWidget' manifest could not be loaded. It was ignored."
I'm using visual studio 2012 in the development and oddly the VS 2012 doesn't show me any error message at all. I'm using Orchard version 1.6.1.0. Can anyone tell me what seems to be the problem? Thanks
It sounds like there is something wrong with your Module.txt. Check that the file is valid, and check your file system permissions for that module.
If that fails, then from searching Orchard's code you should in that the error message is emitted from Orchard.Environment.Extensions.Folders.ExtensionHarvester. Put a breakpoint in the AvailableExtensionsInFolder method in that class and step through until you get an exception message.

Glassfish + CDI results in IncompatibleClassChangeError

Trying my hand at CDI for the first time. I'm using Glassfish v3. When I deploy my app, I get the following failure:
java.io.IOException:
com.sun.enterprise.admin.cli.remote.RemoteFailureException:
Exception while loading the app :
org.glassfish.deployment.common.DeploymentException:
java.lang.IncompatibleClassChangeError:
com.example.arizona.client.ArizonaService
and
com.example.arizona.client.ArizonaService$App
disagree on InnerClasses attribute
at
com.fuhrer.idea.glassfish.server.GlassfishServer3.doParseResponse(GlassfishServer3.java:28)
at
com.fuhrer.idea.glassfish.server.GlassfishServer3Base.parseResponse(GlassfishServer3Base.java:156)
at
com.fuhrer.idea.glassfish.server.GlassfishServer3Base.invoke(GlassfishServer3Base.java:127)
at
com.fuhrer.idea.glassfish.server.GlassfishServer3Base.handleDeployment(GlassfishServer3Base.java:78)
at
com.fuhrer.idea.javaee.server.JavaeeServerInstance$2.run(JavaeeServerInstance.java:131)
I should mention that I'm not even actually using injection, or any other CDI features yet. This is just trying to get the dependencies straightened out.
I've had the same issue, but with Weld in Tomcat. Problem for me was caused by changing an inner class definition to a normal class. Resulted, in my case, in having the old innerclass still in the classes directory but with a new parent class.
Cleaning the classes directory worked for me.
Nearly a year later I'm sorry to say that I never solved this, and for various reasons moved on to another stack altogether: Tomcat, Wicket and Wicket-CDI, all of which have worked great for me.

Team Build sends error when trying to compile a Structuremap method

I'm getting a strange error when trying to compile a solution that is using StructureMap on Team Build.
When I try to compile the solution locally on Visual Studio it works fine, but when trying to queue a new build in Team Build I get the following error:
Overload resolution failed because no accessible 'Use' can be called with these arguments:
The line of code that gets this error is the second one:
ForSingletonOf(Of ISessionFactory)().Use(NHibernateSessionFactory.SessionFactory)
Me.For(Of ISession)().lifecycleIs(New HybridLifecycle()).Use(Function(x) x.GetInstance(Of ISessionFactory)().OpenSession())
It's a standard registration for the NHibernate session, so I don't really get why this error pops up.
Thanks in advance for the clues.
Make sure you have the correct version of NHibernate on the build server, and that your hint paths are all appropriately set in your project file. We haven't had this specific issue (as we're not using NHibernate), but we've had weird issues like that being related to version mismatches of "infrastructure" DLLs between local and build.