gpt4 book ai didi

c# - Ninject 在加载依赖项时抛出异常

转载 作者:行者123 更新时间:2023-11-30 17:10:35 27 4
gpt4 key购买 nike

在开发中成功使用我的应用程序几周后,我将其发送给了我的客户。该应用程序使用 Ninject 来处理依赖项。

当我尝试在客户端机器上运行应用程序时,出现错误:

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()

什么会导致这个异常?

框架 4.0注入(inject) 3.0.0.0

谢谢。

最佳答案

我猜 IoC 容器 (Ninject) 正在寻找一个无法找到的程序集来反射(reflect)。也许一个程序集没有被正确地打包到您的部署中?这也可以解释为什么它可以在您的开发机器上运行,但不能在客户端机器上运行。

关于c# - Ninject 在加载依赖项时抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12045201/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com