1

I'm building my project UnitTest vbproj on Visual Studio 2017 Professional. When I build with "Any CPU", there is one warning:

warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Then I run my test case, all of them are failed. One of error of test case is:

Message: Test method [name of method] threw exception: 
System.BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.

So I change to platform x64 -> there are 45 errors and 8 warning because it's not fit with my project. Then I change to platform x86 -> I received same error with platform x84.

What should I do now? I tried to fix this by many methods but can't.

Mart
  • 13
  • 1
  • 7
  • "AnyCPU" meas the application runs in 64-bit (most likely as nowadays there is no 32-bit Windows anymore). If your application runs in 64-bit mode then you also have to install the 64-bit version of Oracle.DataAccess. In case you like to intall both follow this instruction: https://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100 – Wernfried Domscheit Jun 19 '19 at 10:46
  • I installed Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64 bit Production, but I have not installed Oracle Instant Client and not set java path in enviroment variables of system properties, so I don't know I need install Oracle Client and set java path or not? – Mart Jun 20 '19 at 01:24
  • The Instant Client is just a set of core libraries of an Oracle Client. It is included in any other Client installation, thus you don't have to install it if you have installed anything else. – Wernfried Domscheit Jun 20 '19 at 06:09
  • I read this post: https://stackoverflow.com/questions/49490287/error-while-doing-writing-unit-test-case-could-not-load-file-or-assembly-oracl . And the answer of you and the replies of Jain Prince make me think about installing Oracle Client. – Mart Jun 20 '19 at 06:24
  • Now I reinstalled Oracle database 12c but my unit test is still failed. What should I do? Please give me some advices, thanks. – Mart Jun 20 '19 at 06:26
  • Maybe first remove all Oracle installations completely (see https://stackoverflow.com/questions/8450726/how-to-uninstall-completely-remove-oracle-11g-client) then make **one** fresh installation. – Wernfried Domscheit Jun 20 '19 at 06:30
  • I delete all like this guide: http://www.rebellionrider.com/how-to-uninstall-oracle-database-12c-rebellionrider/ , and I remove almost file except file ewallet.p12 in disk D. Then I install new Oracle Database but I install in other disk (in disk C). Then I run my unit test case but nothing happened differently. – Mart Jun 20 '19 at 06:53
  • It is not really helpful when you just say "I install new Oracle Database". Which options did you enable in the installer? Did you include component "Oracle Data Provider for .NET"? – Wernfried Domscheit Jun 20 '19 at 07:28
  • Thank you for your help. I changed Default Processor Architecture to x64 and all of them are passed. – Mart Jun 20 '19 at 09:49

0 Answers0