错误:无法加载文件或程序集"Oracle.ManagedDataAccessDTC"或其依赖项之一 [英] Error: Could not load file or assembly 'Oracle.ManagedDataAccessDTC' or one of its dependencies

查看:844
本文介绍了错误:无法加载文件或程序集"Oracle.ManagedDataAccessDTC"或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

控制台应用程序执行得很好.

The console application executes perfectly fine.

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

When I try to use the MVC4 application, I see:

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-& Oracle.ManagedDataAccess DLL的64位版本.

I should note that I'm aware this is a bitness issue between 32- & 64-bit editions of the Oracle.ManagedDataAccess DLL.

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

However, why would two projects targeting the same DLL and compiled with the same settings have different results in terms of working?

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

推荐答案

基于您的PrivatePath(C:\ Users \ killesj1 \ Repositories \ PEApps \ src \ app \ PEApps.Web \ bin)和随后的Oracle绑定尝试在该专用路径中的.ManagedDataAccessDTC.DLL,您在应用程序的"bin"目录中拥有ODP DTC程序集的副本.尽管此处未显示,但输出的堆栈跟踪"部分应显示对LoadAllAssembliesFromAppDomainBinDirectory的调用.该方法将尝试加载应用程序"bin"目录中的所有.dll文件.在您的情况下,您在ODP DTC组件的位和执行过程方面不匹配(您已经注意到了这种问题).

Based on your PrivatePath (C:\Users\killesj1\Repositories\PEApps\src\app\PEApps.Web\bin) and the subsequent bind attempt for Oracle.ManagedDataAccessDTC.DLL in that private path, you have a copy of the ODP DTC assembly in the application's "bin" directory. Though you don't show it here, the Stack Trace section of the output should show a call to LoadAllAssembliesFromAppDomainBinDirectory. That method will attempt to load all .dll files in the application's "bin" directory. In your case you have a mismatch with respect to bitness of the ODP DTC assembly and the executing process (you've noted you are aware of this sort of issue).

您未在控制台应用程序中看到此问题的原因是,因为这样的应用程序不会调用LoadAllAssembliesFromAppDomainBinDirectory方法(或类似方法)来预加载"程序集.

The reason you do not see this issue with a console application is because such an application will not call the LoadAllAssembliesFromAppDomainBinDirectory method (or similar) to "preload" assemblies.

关于ODP DTC组件如何进入应用程序的bin目录,也许您无意中包含了对其的引用,并将"Copy Local"设置为"True".或者,您可以将ODP DTC程序集文件添加到项目中,并将复制到输出目录"设置为真".也有可能文件已被手动复制到目录中.换句话说,文件在目录中的结束方式有多种可能性.

As to how the ODP DTC assembly got into the application's bin directory, perhaps you inadvertently included a reference to it and set "Copy Local" to "True". Or perhaps you added the ODP DTC assembly file to the project and set "Copy To Output Directory" to "True". It's also possible that the file was manually copied into the directory. In other words, there are multiple possibilities as to how the file ended up in the directory.

这篇关于错误:无法加载文件或程序集"Oracle.ManagedDataAccessDTC"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆