gpt4 book ai didi

asp.net-mvc - 错误: Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies

转载 作者:行者123 更新时间:2023-12-01 18:13:45 25 4
gpt4 key购买 nike

背景

  • 我有一个包含控制台项目和 MVC4 Web 应用程序的解决方案。
  • 两者均引用 Oracle.ManagedDataAccess(托管 ODP.NET 数据访问提供程序)。引用是同一文件。
  • 均未引用 Oracle.ManagedDataAccess DTC。
  • 在 VS 配置管理器中,所有配置选项的平台都列为“任何 CPU”。
  • 两者的平台目标都是“任何 CPU”

问题

控制台应用程序执行得非常好。

当我尝试使用 MVC4 应用程序时,我看到:

Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Oracle.ManagedDataAccessDTC' could not be loaded.

=== Pre-bind state information ===
LOG: User = [Redacted]\killesj1
LOG: DisplayName = Oracle.ManagedDataAccessDTC
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Oracle.ManagedDataAccessDTC | Domain ID: 13
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/killesj1/Repositories/PEApps/src/app/PEApps.Web/
LOG: Initial PrivatePath = C:\Users\killesj1\Repositories\PEApps\src\app\PEApps.Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\killesj1\Repositories\PEApps\src\app\PEApps.Web\web.config
LOG: Using host configuration file: C:\Users\killesj1\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/killesj1/AppData/Local/Temp/Temporary ASP.NET Files/root/e17fc384/1ed8df51/Oracle.ManagedDataAccessDTC.DLL.
LOG: Attempting download of new URL file:///C:/Users/killesj1/AppData/Local/Temp/Temporary ASP.NET Files/root/e17fc384/1ed8df51/Oracle.ManagedDataAccessDTC/Oracle.ManagedDataAccessDTC.DLL.
LOG: Attempting download of new URL file:///C:/Users/killesj1/Repositories/PEApps/src/app/PEApps.Web/bin/Oracle.ManagedDataAccessDTC.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

我应该指出,我知道这是 32 位和 64 位版本的 Oracle.ManagedDataAccess DLL 之间的位数问题。

但是,为什么两个针对相同 DLL 并使用相同设置编译的项目在工作方面会产生不同的结果?

到目前为止,我已经尝试过...

  • 从 IIS Express 切换到 Cassini 只是为了好玩...同样的问题
  • 尝试以同样的方式使控制台应用程序失败...到目前为止还没有。

最佳答案

根据您的 PrivatePath (C:\Users\killesj1\Repositories\PEApps\src\app\PEApps.Web\bin) 以及该私有(private)路径中 Oracle.ManagedDataAccessDTC.DLL 的后续绑定(bind)尝试,您拥有以下副本应用程序的“bin”目录中的 ODP DTC 程序集。尽管此处未显示,但输出的堆栈跟踪部分应显示对 LoadAllAssembliesFromAppDomainBinDirectory 的调用。该方法将尝试加载应用程序“bin”目录中的所有 .dll 文件。在您的情况下,您的 ODP DTC 程序集位数和执行过程不匹配(您已经注意到您已经意识到此类问题)。

您在控制台应用程序中没有看到此问题的原因是,此类应用程序不会调用 LoadAllAssembliesFromAppDomainBinDirectory 方法(或类似方法)来“预加载”程序集。

至于ODP DTC程序集如何进入应用程序的bin目录,也许您无意中包含了对它的引用并将“Copy Local”设置为“True”。或者,您可能将 ODP DTC 程序集文件添加到项目中并将“复制到输出目录”设置为“True”。该文件也可能是手动复制到目录中的。换句话说,文件最终进入目录的方式有多种可能性。

关于asp.net-mvc - 错误: Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15006449/

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