0

I am using Visual Studio, Test Complete and C#. I am basing it off another project which also uses the same. This other project uses Oracle to query and works fine.

I based all my settings on the other project (any CPU, all the same references, etc). However, when I run it and attempt to connect to oracle I get an exception about a bad image (this happens when you run 64 bit and try to load a 32-bit client). I copied all the references, and tried all combinations of build. I do think I am running 64-bit because when I am debugging and try to insert a line it says it is disallowed in 64-bit mode. On the other application it lets me insert lines during debugging.

Here is the exception:

    e   {"Attempt to load Oracle client libraries threw BadImageFormatException.  This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed."} System.Exception {System.InvalidOperationException}

I try replacing the oracle library but it always seems to go back. Better would be to run in 32-bit mode. As you can see from the picture, for some reason "Prefer 32-bit" is disabled (also in the application that works).

Any idea what to do? This will also, once it runs on my machine, be transferred to another. This is Visual Studio 2012 (11.061219.00)

enter image description here

Tony
  • 1,127
  • 1
  • 18
  • 29

1 Answers1

0

Use connection.GetType().Assembly.Location to check which DLL is actually loaded.

Typically (and simplified, see How the Runtime Locates Assemblies) assemblies are loaded from GAC (Global Assembly Cache) or from directory where your .exe is stored. Note, the GAC takes precedence!

If a .exe or .dll file is x86 or x64, you can check with sigcheck tool.

In Oracle Client 12.1 Setup and later the ODP.NET is not added to GAC anymore, you need to add it manually.

You may use my Oracle Connection Tester which could show you the problem of your installation.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • Thanks. I read that site. I specify the complete path to the library files by doing an "add reference" and browsing to the library. So that is the full path. It appears that when I build, it copies the libraries into my won directory. These are the same libraries used by other projects that work. Do you know what object file that main() is in? That may be the 64 bit. That should be the .exe file? I think it is vstest.console.exe? That is the name when we run standalone on another machine. – Tony Apr 05 '22 at 10:17