9

We are using a Third-Party assembly that seems to be compiled as AnyCPU.

However, we have a number of installations of our application where this leads to problems. This Third-Party assembly makes use of the oracle dataaccess library, and will not work on 64-bit machines where only a 32-bit oracle client is installed.

Installing a additional 64-bit oracle client would be possible, but also expensive (takes a lot of time, many machines have to be updated etc.)

Is there a way to force a AnyCPU .Net assembly to run as 32-bit without recompiling?

2 Answers 2

8

Have a look at CorFlags.exe.

Example (set 32BIT flag):

corflags [path]\[YourAssembly.exe] /32Bit+
3
  • +1. An example is lextm.com/2009/03/sharpdevelop-on-x64-windows-issue.html
    – Lex Li
    Jun 8, 2012 at 8:52
  • All changing the flags on the 3rd party assembly will do is cause a runtime error if loaded into a 64 bit process (see doco msdn.microsoft.com/en-us/library/ms164699(v=vs.110).aspx). OP already has a runtime error, so I can't see this helps much :-/. He needs to change the flags on the EXE that starts the process, and whilst he could use corflags for this (ie in-the-field), long term it's massively simpler just to retarget to x86 at compile-time
    – piers7
    Jan 29, 2015 at 4:08
  • @piers7 "He needs to change the flags on the EXE that starts the process": Yes, that's what my answer says. "and whilst he could use corflags for this (ie in-the-field)": Yes, that's what OP asked for.
    – sloth
    Jan 29, 2015 at 7:56
8

Assuming that you are building the .EXE that has a reference to a AnyCPU third party assembly you need to build your project as x86. This project can reference AnyCPU assemblies but being marked as x86 it will run as a 32 bit process on both 32 bit and 64 bit Windows.

1
  • This is a better answer for the OP's actual problem
    – piers7
    Jan 29, 2015 at 4:04

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.