So, we just changed our app pool to 64 bit runtime, after that I got

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.

We definetely don't use Oracle and have no references to its libs. SO i suppose it is DO who uses it, but why?


Updated at 03.06.2010 12:34:52

4.3RC2


Updated at 03.06.2010 12:40:16

Most likely this happens because: - There is indirect reference to it via Xtensive.Storage.All.dll -> Xtensive.Sql.All.dll -> -> Xtensive.Sql.Oracle.dll. CopyIndirectDependencies target from DataObjects.Net.targets ensures all indirect dependencies are copied to Bin folder, including this one - we intentionally implemented this to ensure all the providers are copied to Bin folder to enable application to run on any supported DB without any additional copying, etc. - Thus 32-bit Oracle.DataAccess.dll is copied to Bin folder - Finally, you have some code that leads to loading of all the assemblies into the application Domain (e.g. it enumerates them). Try the following: - Remove assembly from Bin folder - If this won't help, enable Fusion Log to find out who is responsible for its loading. Do u propose to remove this assembly from Bin every build?


Updated at 03.06.2010 12:42:39

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.

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.DataAccess' 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.DataAccess' could not be loaded.

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\SYSTEM
LOG: DisplayName = Oracle.DataAccess
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Oracle.DataAccess | Domain ID: 2
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:/Home/Docs/Visual Studio 2010/Projects/Platform/Werp.View/
LOG: Initial PrivatePath = D:\Home\Docs\Visual Studio 2010\Projects\Platform\Werp.View\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Home\Docs\Visual Studio 2010\Projects\Platform\Werp.View\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\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:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/web.tester/c622f5ee/11cf6380/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/web.tester/c622f5ee/11cf6380/Oracle.DataAccess/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///D:/Home/Docs/Visual Studio 2010/Projects/Platform/Werp.View/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, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118

[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) +11392147
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087

[HttpException (0x80004005): 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.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Jun 03 '10 at 11:43

xumix's gravatar image

xumix
425757682

What version of DO do you have? This was happing to me with version 4.1 but not now (4.2 or 4.3RC2)

(Jun 03 '10 at 11:43) Peter Ĺ ulek Peter%20%C5%A0ulek's gravatar image

One Answer:

Most likely this happens because:

  • There is indirect reference to it via Xtensive.Storage.All.dll -> Xtensive.Sql.All.dll -> -> Xtensive.Sql.Oracle.dll. CopyIndirectDependencies target from DataObjects.Net.targets ensures all indirect dependencies are copied to Bin folder, including this one - we intentionally implemented this to ensure all the providers are copied to Bin folder to enable application to run on any supported DB without any additional copying, etc.

  • Thus 32-bit Oracle.DataAccess.dll is copied to Bin folder

  • Finally, you have some code that leads to loading of all the assemblies into the application Domain (e.g. it enumerates them).

Try the following:

  • Remove assembly from Bin folder

  • If this won't help, enable Fusion Log to find out who is responsible for its loading.


Log shows it is actually available here: D:\Home\Docs\Visual Studio 2010\Projects\Platform\Werp.View\bin

Exception Details: System.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.


> Do u propose to remove this assembly from Bin every build?

Yes, if this will help, this should be done. But this can be automated via e.g. PostBuildEvent in .csproj:

<PropertyGroup>
    <PostBuildEvent>del /A "$(ProjectDir)Bin\Oracle.DataAccess.dll"</PostBuildEvent>
  </PropertyGroup>

Another possible solution (the standard one) is to remove reference to Xtensive.Storage.All assembly, but add all the references you'll need in Bin directly (there must be many of them).

Actually, the most annoying thing here is ODP.NET provider itself:

  • They ship different versions of ODP.NET for 32 and 64 bit platforms. Why? Who knows, it's Oracle.

  • So if you build .NET library targeting any platform (e.g. our Oracle provider), you can't link to any of it. This is recursive: any other assembly compiled for a particular platform (and linking its particular version) can't be statically referenced from assembly targeting multiple platofrms.

So in fact, we should build two versions of assembly of our Oracle provider (with absolutely identical code!) + implement some special provider resolution case just because by some absolutely unclear reason they don't have multiplatform version of Oracle.DataAccess for .NET. And, as you already know, this also leads to your issue. Actually, I hate Oracle for such things...


We don't load it, it is loaded by ASP.NET compilation framework while it inspects references. Stack trace in fusion log shows this line:

System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334

So the only workaround I can suggest now is:

  • Remove reference to Xtensive.Storage.All.dll and Xtensive.Sql.All.dll assemblies from your projects

  • Add all the references you need direcdtly to each of projects.

answered Jun 03 '10 at 12:35

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Deleting the assembly does not help

(Jun 03 '10 at 12:35) xumix xumix's gravatar image

I've deleted the assembly everywhere. There is no Oracle sh*t in temp or project folders but the problem is still here. I suppose you should implement some detection mechanism and stop loading Oracle when it is not needed.

(Jun 03 '10 at 12:35) xumix xumix's gravatar image

or go to the bin folder of your project and delete oracle.dataaccess

it's damn annoying have to do that each time you build... so probably smart to use a build script

(Jun 03 '10 at 12:35) ara ara's gravatar image

e.g. go to your project properties, click "build events" tab, in post-build event command line section enter:

del $(TargetDir)Oracle.DataAccess.dll
(Jun 03 '10 at 12:35) ara ara's gravatar image

I can integrate this to DataObjects.Net.targets (as temporary fix).

(Jun 03 '10 at 12:35) Alex Yakunin Alex%20Yakunin's gravatar image

Xtensive.Storage.All.dll; Xtensive.Sql.All.dll So, which assemblies do I need instead for MS Sql?

(Jun 03 '10 at 12:35) xumix xumix's gravatar image

All Xtensive.*, but except:

  • *.All
  • Xtensive.Sql.*

and including Xtensive.Sql.SqlServer.

(Jun 03 '10 at 12:35) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA