tags:

views:

32

answers:

2
+3  Q: 

C++/CLI 64-bit COM

I have a C++/CLI assembly that wraps a native 32-bit dll.

The assembly is used both from .Net and COM (office).

Now I have a customer that runs 64-bit office.

Is it possible to create a C++/CLI assembly that uses a native 32-bit dll and exports a 64-bit com interface?

+2  A: 

No, you can't mix code with different bitness in one process on Windows. You need to force 32-bit code into a separate process or convert that DLL.

The latter can likely be achieved by using COM+ (or DCOM which is mostly the same). This is what we usually do with native C++ code. I'm not sure about how easy it is with C++/CLI assemblies.

sharptooth
That is what I suspected. Thanks
adrianm
Since the Office/plugin interface is already COM, might as well do the proxy there instead of introducing a new translation layer between the C++/CLI and the native library.
Ben Voigt
A: 

In a manner of speaking, yes.

Continue to compile the C++/CLI code as 32-bit so it can use the native library using C++ interop.

Then you will have to configure it to load as an out-of-process COM server when acting as an Office 64 plugin. With native COM code, midl automatically generates the 64-bit proxy. There should be some similar capability to create a proxy when registering .NET classes marked COMVisible.

The 64-bit COM interface will be contained in the auto-generated 64-bit proxy DLL, so this doesn't violate the rule that the bitness of all modules in a process must be the same.

Ben Voigt