Samuel
Samuel

Reputation: 12351

Ninject throw an exception while loading dependencies

After using my application successfully in development for a couple of weeks, I shipped it to my client. The application use Ninject to handle dependencies.

When I try to run the application on the client machine, an error occurs:

Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at Ninject.Infrastructure.Language.ExtensionsForAssembly.HasNinjectModules(Assembly assembly)
   at Ninject.Modules.AssemblyNameRetriever.AssemblyChecker.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter)
   at Ninject.Modules.AssemblyNameRetriever+AssemblyChecker.GetAssemblyNames(System.Collections.Generic.IEnumerable`1<System.String>, System.Predicate`1<System.Reflection.Assembly>)
   at Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(System.Collections.Generic.IEnumerable`1<System.String>, System.Predicate`1<System.Reflection.Assembly>)
   at Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(System.Collections.Generic.IEnumerable`1<System.String>)
   at Ninject.Modules.ModuleLoader.LoadModules(System.Collections.Generic.IEnumerable`1<System.String>)
   at Ninject.KernelBase..ctor(Ninject.Components.IComponentContainer, Ninject.INinjectSettings, Ninject.Modules.INinjectModule[])
   at MyApplication.Main.Application_Start()
   at MyApplication.Main..ctor()
   at MyApplication.Program.Main()

What can cause this exception?

Framework 4.0 NInject 3.0.0.0

Thank you.

Upvotes: 3

Views: 1014

Answers (1)

Brian Knight
Brian Knight

Reputation: 5041

I would guess that the IoC container (Ninject) is looking for an assembly to reflect upon that cannot be found. Perhaps an assembly is not being packaged propely with your deployment? That could also explain why it works on your development machine but not on the client machine.

Upvotes: 2

Related Questions