views:

153

answers:

1

This is very odd.

We have some managed C++ (an assembly) which uses a .NET COM interop dll generated by TlbImp to make calls into a COM object. When we register the COM DLL we specify that we want it to execute within a surrogate (the "DLLSurrogate" registry entry).

Our COM DLL is 64-bit and is executing on a 64-bit platform.

When we integrate the assembly with a 32-bit application (which contains managed and unmanaged code) calls into the COM library execute within DllHost. A 64-bit build of the same application causes the calls to be executed within the calling process.

Pure unmanaged client applications (both 32 and 64 bit) execute properly on the 64-bit system which shows (I hope) that we have configured / installed the COM library properly.

This behaviour could indicate that the .NET COM Interop is ignoring the configuration information in the registry. The 32-bit client cannot load the 64-bit COM DLL into its address space and defaults to using a surrogate? Anyway, this behaviour is disastrous for us as the COM library contains a singleton representing access to some hardware and there maybe many client processes.

Has any one noted this behaviour before?

Thanks,

Mike D

+1  A: 

This is an odd request, it is almost always the other way around; trying to use a 32-bit COM server from 64-bit code. If you have a 32-bit build of the server, then be sure to use it in-process, much more efficient and easier to get going than an out-of-proc surrogate.

The registry on a 64-bit version of Windows is virtualized for 32-bit apps. All 32-bit COM registration is stored in the HKLM\Software\Wow6432Node. Use Regedit.exe to verify that the COM server registration is actually present there.

You may also have an issue with the proxy/stub DLLs for the COM server. They'll be needed because your server runs in another process. Be sure to build those DLLs both in 32-bit and 64-bit versions and register them with the proper version of Regsvr32.exe

Hans Passant
Thanks. Everything checks out.We've used the COM server for a number of years with 32 and 64-bit unmanaged clients accessing the 64-bit server. It's the .Net Interop layer which is new and causing us grief.We need to run out of process to implement our singleton pattern. The COM object accesses a driver which requires 64-bit clients hence the 64-bit COM server.
Mike D