Andy
Andy

Reputation: 11462

.Net COM interop with 32 and 64 bit platforms

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

Upvotes: 1

Views: 4973

Answers (4)

Bala
Bala

Reputation: 648

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'.

Upvotes: 0

David Heffernan
David Heffernan

Reputation: 612784

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.

Upvotes: 1

cichy
cichy

Reputation: 10634

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

Upvotes: 1

sehe
sehe

Reputation: 392833

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

Upvotes: 0

Related Questions