在 Web 应用程序中加载文件或程序集时出错

Error loading file or assembly in Web Application

我需要专业人士的帮助, 我正在尝试在我的服务器上安装 DevInfo 7 Web 应用程序,SQL 服务器和 IIS 有很多问题,2 天后,我设法修复了它,但现在 IIS 和 SQL工作正常,我无法克服这个错误,因为我不知道这种语言(顺便说一句,我会添加一些标签,但因为我不知道这种语言,我不确定它们是否真的与问题是,如果我选错了标签,告诉我我把它拿走了!)

如果有人能向我解释问题出在哪里或如何解决,我将不胜感激,因为我没有创建 Web 应用程序(我不知道如何创建),而只是尝试安装一,我可能没看懂(请尽量简单点)

我不知道这是否会改变某些东西,但我将其安装在 Windows Server 2012,x64...

这是错误:


“/devinfo”应用程序中的服务器错误。

无法加载文件或程序集 'DI5_INIFile' 或其依赖项之一。试图加载格式不正确的程序。 说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

异常详细信息:System.BadImageFormatException:无法加载文件或程序集 'DI5_INIFile' 或其依赖项之一。试图加载格式不正确的程序。

来源错误:

在执行当前网络请求期间产生了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

程序集加载跟踪:以下信息有助于确定无法加载程序集 'DI5_INIFile' 的原因。

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

堆栈跟踪:

[BadImageFormatException: Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'DI5_INIFile' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

听起来好像进入了.net版本的地狱。当存在冲突的 dll 版本时,我遇到了这个问题。

要尝试的事情: 1 - 清理您的解决方案(右键单击 Visual Studio 中解决方案树的顶部并单击 "Clean"),然后执行全部重建。

2 - 如果这不起作用,请清除项目的 ../bin/Debug 文件夹,然后重复步骤 1。如果这是一个 Web 应用程序并且您有本地版本的 IIS 运行,您应该首先考虑重置 IIS。这将释放进程对您的 bin 文件夹中的 dll 的所有锁定。

3- 除了步骤 2,您还可以清除 ../obj 文件夹。但是,清理和重建 应该 为您完成此操作。

4 - 还可以尝试清除临时 asp.net 文件: del /F /Q "%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET 文件"

5 - 如果失败,您将需要查看哪个项目正在尝试引用 'DI5_INIFile' 并检查其版本号(右键单击 dll > 属性 > 版本)并查看它是否在您的web.config 在不同的版本号下。 如果是,您可以从您的项目中删除引用的程序集,然后尝试重新添加它。

希望对您有所帮助!