Search code examples
c#nunitteamcityoledb

Run a specified NUnit test as a 32-bit process in a 64-bit environment


I have a component that uses OLEDB to import data from an Excel file. Due to business risk and time constraints, my executable shell is compiled as x86 (32-bit) to avoid the 64-bit OLEDB problem and the component runs flawlessly when loaded into my 32-bit shell.

However, my CI build process (TeamCity) is running its TestRunner in a 64-bit process and so unit tests targeting the above functionality are failing with the usual error message:

Test(s) failed. System.InvalidOperationException : The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

My solutions would appear to be

  1. Change the CI test runner - not feasible as the testrunner is used by 10 other teams
  2. Ensure this test is run in a 32-bit process

So, is there a way to tell NUnit, or the TeamCity NUnit test runner, to run a specific test in a 32-bit process? Ideally, I'd like the same tests to run unmodified in both IDE and CI.


Solution

  • Changing the "Platform target" to x86 on the unit test project should do the trick.