0

I'm now writing a snap-in for MMC3.0, it should support both x64 and x86 platform, but the GUID should be different. In C++ I know there are macros like _WIN32, but I can't find something like this in C#. My target is to let the code looks like

#ifdef _WIN32
[SnapInSettings("x86_guid")]
#else
[snapInSettings("x64_guid")]
#endif

x86_guid and x64_guid should be constant.

I have been looking around for a while, but no answer.

aquaraga
  • 4,138
  • 23
  • 29
Joey Yu
  • 71
  • 4

1 Answers1

0

You can create a new solution / project platform for a 64-bit build and then define different GUID-s for the different platforms. You'll then build 2 DLL-s of your MMC snap-in: one for 32-bit platforms and one for 64-bit platforms.

In Build->Configuration Manager create a new build platfom (for example x64) and then go to the Build in Project properties to define a new symbol for your x64 build target. This would be something like _WIN64. You can leave the Platform target dropdown as Any CPU, just make sure that the 64-bit MMC loads your _WIN64 build version. (I'm not familiar with how to set up MMC snap-ins so I don't know what this involves.)

Once you do the above configuration steps, you can now pretty much duplicate your C++ code in C# to check for build target:

#ifdef _WIN64
[SnapInSettings("x64_guid")]
#else
[snapInSettings("x86_guid")]
#endif

The GUID-s would be hardcoded strings so they'd be constants.

xxbbcc
  • 16,930
  • 5
  • 50
  • 83
  • thanks for your reply.i don't know if i understand it correctly, if i follow the way, i need maintain 2 copy for a same code. it's too hard, at last i decided to undefine all TRACE marcro for x86 configuration and define TRACE for all x64 configuration no matter release or debug. use the TRACE flag as platform macro. – Joey Yu Jul 15 '13 at 09:06
  • @JoeyYu No, you don't need to maintain 2 copies of the code. You need to have 2 copies of the resulting DLL, but this would be the same with C++ as well. You'll just have a single code base and you'll have to build it twice - once for x86 and once for x64. – xxbbcc Jul 15 '13 at 09:16