Asp.net 目标平台和';无法加载文件或程序集';错误

Asp.net 目标平台和';无法加载文件或程序集';错误,asp.net,winforms,assemblies,target-platform,Asp.net,Winforms,Assemblies,Target Platform,我有一个针对64位平台的Win Forms应用程序(它是必需的,因为它使用64位Oracle.DataAccess库) 我已将ASP.net表单应用程序添加到此解决方案中,我想将WinForms应用程序的引用添加到ASP.net应用程序中 我的WebApp也以64位为目标并正确构建,但当我运行它时,我得到: “无法加载文件或程序集”Oracle.DataAccess“或其依赖项之一” 我还确保Oracle.DataAccess是新的64位版本。 有什么想法吗? Winforms应用程序(引用了O

我有一个针对64位平台的Win Forms应用程序(它是必需的,因为它使用64位
Oracle.DataAccess
库)

我已将ASP.net表单应用程序添加到此解决方案中,我想将WinForms应用程序的引用添加到ASP.net应用程序中

我的WebApp也以64位为目标并正确构建,但当我运行它时,我得到:

“无法加载文件或程序集”
Oracle.DataAccess
“或其依赖项之一”

我还确保Oracle.DataAccess是新的64位版本。 有什么想法吗?
Winforms应用程序(引用了Oracle.DataAccess)正在100%运行,这说明问题可能不在dll版本上

有关错误的详细信息如下:

=== Pre-bind state information ===
LOG: User = Domain\myUser
LOG: DisplayName = Oracle.DataAccess
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Oracle.DataAccess | Domain ID: 3
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:///D:/xx/UDWIntegration/UDWWeb/
LOG: Initial PrivatePath = D:\xx\UDWWeb\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\xx\UDWWeb\web.config
LOG: Using host configuration file: C:\Users\xx\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/xx/AppData/Local/Temp/Temporary ASP.NET Files/root/ef51aef3/7f23a77a/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///C:/Users/xx/AppData/Local/Temp/Temporary ASP.NET Files/root/ef51aef3/7f23a77a/Oracle.DataAccess/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///D:/xx/UDWWeb/bin/Oracle.DataAccess.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' 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.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'Oracle.DataAccess' 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) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +124
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +44
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +187
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +74
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +43
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
   System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path) +37
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
使用C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config中的计算机配置文件

您的跟踪清楚地显示您的代码正在32位模式下运行。64位程序从c:\windows\microsoft.net\framework64目录加载machine.config文件。因此,BadImageFormatException是完全可以预料的


它不是由您的项目来配置在什么模式下运行,而是由IIS中的应用程序池配置来选择位。使用中所示的高级设置进行配置。请确保您与正常配置机器的人交谈,此设置更改不是意外事件。

这可以通过从下载并执行“odac11230xcopy.zip”中的install.bat文件来解决

如果在Visual Studio(VS)中使用IIS Express运行/调试web应用时遇到此问题,请确保选中以下设置:


工具>选项>项目和解决方案>Web项目>将64位版本的IIS Express用于网站和项目

是否检查了Oracle.DataAccess dll上的引用?也许您的应用程序试图从另一个只有x86版本的地方加载它。此外,请确认在构建平台设置为x64时,所有项目的项目属性->构建->平台目标均为x64。请检查两个应用程序的项目属性中的目标框架,并确保它们匹配。默认情况下,WinForms将以“.NET Framework 4客户端配置文件”为目标,而不是“.NET Framework 4”。我仔细检查了这两个项目是否在x64上。我重新下载了Oracle.DataAccess 64位dll,并确保引用了该dll。您是否已将Oracle.DataAccess dll的副本放入项目的bin文件夹中?这就是它试图加载它的地方。Visual Studio不会将dll从引用位置复制到bin文件夹。你必须手动操作。是的,我也这么做了-谢谢。谢谢-在设计期间是否有可能在我的开发机器上更改此设置(即尚未部署到IIS上)?第一次谷歌点击:我也看到了,但事实上,它声明它未经完全测试,这让我担心。我确实试过了,但还是没有成功。我还尝试在启用了32位的IIS上进行部署,但仍然存在此错误。然而,我认为某些东西确实起了作用,因为错误消息看起来有些不同。因此,我将接受你的回答。谢谢