1

I am using a third party COM component and the vendor has supplied both 32 and 64 bit versions of it. I want to build my .NET application for "any cpu" and have it invoke the 32 bit COM component if the process is 32 bit, or the 64 bit component in 64 bit mode.

Can anyone point me at any useful resources to describe how this process works? does it just happen by magic if I register the correct COM component?

Thanks

Andy

Andy
  • 10,412
  • 13
  • 70
  • 95
  • See [Dynamically loading an assembly based on whether current process is x32 or x64](http://stackoverflow.com/questions/23155470/dynamically-loading-an-assembly-based-on-whether-current-process-is-x32-or-x64). – Joshua Drake Sep 23 '14 at 21:13

4 Answers4

1

This could be useful: Using Side-by-Side assemblies to load the x64 or x32 version of a DLL

Community
  • 1
  • 1
cichy
  • 10,464
  • 4
  • 26
  • 36
1

A 32 bit process will load the 32 bit COM server and a 64 bit process will load the 64 bit COM server. In other words, so long as you install the right COM server on the target machine, you should have to do precisely nothing for this to just work.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thanks, I presume this is true in the general case. However, it seems that for the component I was using, the suppliers have used a different ProgId for the 64 bit component (which therefore generates a different namespace in the .Net interop). Anyway I was able to add both DLL references at the same time and put in a switch to call one or the other depending on Sizeof(IntPtr). Not ideal but it works – Andy Jun 10 '11 at 11:18
  • Hmm, I'm pretty hazy about `ProgId` so I wouldn't like to comment! – David Heffernan Jun 10 '11 at 11:19
0

Use 32 bit COM dll.

If you application type is Web, Refer your 32 bit COM dll and deploy the app. In IIS Set 'Enable 32bit Application = TRUE.

In Windows App, Just refer the 32 bit dll and build the app with 'Any CPU'.

Bala
  • 618
  • 5
  • 21
0

AFAICT COM is (has always been) a binary standard interface.

It's definition will not depend on byte-ordering, word-size or other architecture dependent details. It is perfectly possible (and not even that difficult, for simple interfaces) to code a COM component that complies with all of that in plain C code.

Certain indivuals (Don Box, Craig Brockschmidt, I have a feeling I'm somehow forgetting about the most known one... bad memory) have been quite famous for writing books about how COM is implemented in just that way.

If you want any confirmation, you can confirm that the output of MIDL doesn't depend on your platform characteristics

sehe
  • 374,641
  • 47
  • 450
  • 633