Ninject and Assembly Bindings in an Azure Function

342 Views Asked by At

I have an Azure Function that is relying on other assemblies which in turn relies on Ninject for dependency injection. During runtime, Ninject seems to fail to resolve a dependency for some custom Ninject.Activation.Provider<T>, resulting in a System.IO.FileNotFoundException.

The Ninject part of the stack-trace is:

at Ninject.Activation.Provider`1.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(Object scope) at Ninject.Activation.Context.Resolve() at Ninject.KernelBase.<>c__DisplayClass15.b__f(IBinding binding) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at Ninject.Planning.Targets.Target`1.GetValue(Type service,IContext parent) at Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) at Ninject.Activation.Providers.StandardProvider.GetValue(IContext context,ITarget target) at Ninject.Activation.Providers.StandardProvider.<>c__DisplayClass4.b__2(ITarget target) at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at Ninject.Activation.Providers.StandardProvider.Create(IContext context) at Ninject.Activation.Context.ResolveInternal(O…

The dependency not resolved is to System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (or one of it's dependencies). It's included into the project via NuGet.

This assembly in question however, does actually exist on disk in the bin folder of the Azure Function, and the build itself is fine. My theory, therefore, is that Ninject does something peculiar when instantiating the custom Provider<T>.

Maybe Ninject expects the dependencies to be gathered at another location, relative to where the Function executes or something? Maybe it's not Ninject at all that is to be blamed, but rather some particular when it comes to how dependencies are resolved in the Azure environment that I'm unaware of?

I'm hoping that one of you can help me out by shedding light on what's going on here, or suggest a smart troubleshooting move, 'cause I've drawn all blanks for a couple of days now.

If that's the case to be, I can influence how the people responsible for the custom Provider<T> addresses things in their code, so possible solutions include this venue.

Thank you beforehand!

0

There are 0 best solutions below