0

I have a .h file that is externally generated and includes enums and strings I need to reference in my C# code.

To 'solve' this, I created a C++/CLI project to encapsulate the information in a class I can access from C#. This worked fine for me (running Windows 7 - 32 bit).

All has gone well until someone tried to run it on x64 and he got BadImageFormatException.

There is ONE LINE in the external .h that is keeping me from being able to build /clr:safe:

static const char* const NiFpga_M_OTRM_OVDFPGA_Signature = "C2BF591011B5C7046AB3528D7EFEFC72";

If it was just this instead, all would be fine:

#define NiFpga_M_OTRM_OVDFPGA_Signature = "C2BF591011B5C7046AB3528D7EFEFC72";

ARG! The application needs to build and run on both 64-bit and 32-bit Windows 7.

Any recommendations (that allow me to leave the .h file intact).

markshancock
  • 690
  • 2
  • 7
  • 25
  • 32 bits programs run fine on Windows 64 bits, using WoW64. Do you really need to *build* 64 bits versions? – manuell Feb 19 '14 at 15:34
  • This is a Realtime application and we are concerned about restricting it the 32-bit only. We want to be prepared for moving to x64 in the future. Most of the code is built as "Any CPU" and runs fine on either platform. It is just having to use C++/CLI to import of the address map information in the .h file that is placing restrictions. – markshancock Feb 19 '14 at 17:06
  • What you're really looking for is already answered here: http://stackoverflow.com/questions/2963809/anycpu-x86-x64-for-c-sharp-application-and-its-c-cli-dependency And here: http://stackoverflow.com/questions/7727876/any-cpu-dependent-on-c-cli-dependent-on-native-c-dll-any-cpu-for-c-cli – leetNightshade Feb 19 '14 at 17:27
  • I know I can create create separate 32 and 64 project builds then dynamically load the correct one based on the platform. I was hoping someone had a creative way to deal with the string since that is my only issue. I was considering a pre-compile step to modify the .h file; but, that seems like it may be a bit to 'creative'. – markshancock Feb 19 '14 at 20:40

0 Answers0