ICallFactory with 32-bit and 64-bit type libraries side by side
NickName:Michael Gunter Ask DateTime:2015-06-11T08:23:23

ICallFactory with 32-bit and 64-bit type libraries side by side

I have a in-proc COM server for which I want to build 32-bit and 64-bit versions. I can do this with no problem. However, I am encountering some issues when both versions are registered.

I am not using ATL. In my DllRegisterServer function, I am using RegisterTypeLibForUser. I am acquiring the ITypeLib instance for the RegisterTypeLibForUser call by calling LoadTypeLibEx with my DLL's path, and I am using the REGKIND_NONE flag. I am creating my type library using .idl and the MIDL compiler. I am embedding the type library in my .dll as a resource. Given the first two bullets below (where everything works as expected), there doesn't seem to be any issues with the way that I'm doing this.

  • If I register ONLY 32-bit, everything works fine in a 32-bit client, and I get expected failures in a 64-bit client (class not registered).
  • If I register ONLY 64-bit, everything works fine in a 64-bit client, and I get expected failures in a 32-bit client (class not registered).
  • If I register 64-bit followed by 32-bit, everything works fine in a 32-bit client, but I get failures in a 64-bit client. If I then unregister the 32-bit server, the 64-bit client continues to fail. If I re-register the 64-bit server (with or without unregistering), the 64-bit client works.
  • If I register 32-bit followed by 64-bit, everything works fine in a 64-bit client, but I get failures in a 32-bit client. If I then unregister the 64-bit server, the 32-bit client continues to fail. If I re-register the 32-bit server (with or without unregistering), the 32-bit client works.

It appears that when I register both servers, the latter RegisterTypeLibForUser call does something that screws up the registry settings for the previous RegisterTypeLibForUser call.

As for the errors I'm getting:

  • CoCreateInstance always works as long as the correct server is registered. In a 32-bit client, CoCreateInstance works as long as the 32-bit server is registered (even if the 64-bit server is also registered). Ditto for 64-bit client with 64-bit server.
  • In any situation where CoCreateInstance works, I can invoke methods on the object. I can marshal my interfaces between apartments (I'm using the global interface table), and I can invoke methods on the marshaled interfaces.
  • The errors I'm getting are specifically related to ICallFactory in an apartment to which the interfaces have been marshaled. I can query for ICallFactory on the marshaled interface without any problem. But when I call CreateCall with the IID of my asynchronous interface, I receive the error E_NOINTERFACE.
  • As mentioned in the previous list, I do not receive this error as long as the server that was last registered is the one with the same target platform as the client.

I'm trying to dig through my registry now and figure out exactly what is being changed as the registrations are happening, but due to the registry redirector, this isn't so simple. I will update this post as I uncover the registry information.

Copyright Notice:Content Author:「Michael Gunter」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30769574/icallfactory-with-32-bit-and-64-bit-type-libraries-side-by-side

More about “ICallFactory with 32-bit and 64-bit type libraries side by side” related questions

ICallFactory with 32-bit and 64-bit type libraries side by side

I have a in-proc COM server for which I want to build 32-bit and 64-bit versions. I can do this with no problem. However, I am encountering some issues when both versions are registered. I am not ...

Show Detail

Loading a 32-bit or 64-bit side-by-side COM DLL depending on the bitness with which the application runs

I have a .NET application that uses a COM DLL, of which there is both a 32bit and a 64bit version. I have written two application manifests that make side-by-side COM interop work on either 32 Bit ...

Show Detail

Developing for both 64-bit and 32-bit

I've read a lot on the subject of converting 32-bit to 64-bit. I use a lot of vendor hardware, and have finally obtained both 64-bit and 32-bit drivers for each. Moving from 32 to 64 seems like it ...

Show Detail

Convert 32-bit compiled open source libraries to 64-bit compiled libraries

In my project, I am having set of open source libraries that are 32-bit compiled. How to compile those libraries in a such a way that the libraries should be 64-bit compatible? How to make 64-bit

Show Detail

How to link a 32-bit DLL for 64-bit WINE against 64-bit Linux libraries only?

I am using WINE (on 64-bit Linux) to run a 32-bit Windows application which loads a DLL (LoadLibrary). I would like to re-write the DLL and compile it with winegcc/winebuild for that environment, w...

Show Detail

Cannot load 32-bit SWT libraries on 64-bit JVM

My computer is win7 64 bit, and jdk is 1.7.0.21,jvm is 1.6.. and 64 bit I want to run SWT application and export as runnable jar file. When I run the application, it has the exception that Cannot ...

Show Detail

64-bit GCC mixing 32-bit and 64-bit pointers

Although the code works, I'm baffled by the compiler's decision to seemingly mix 32 and 64 bit parameters of the same type. Specifically, I have a function which receives three char pointers. Looki...

Show Detail

Cannot load 64-bit SWT libraries on 32-bit JVM (even though I downloaded 32-bit SWT)

I am currently developing on a 64-bit Windows 7 machine. I have JRE7 64-bit and JRE7 32-bit installed on my machine. I am using Eclipse 64-bit version and configured Window - Preferences - Java -

Show Detail

32-bit library on 64-bit system

Can it cause any problem if I use 32-bit library on a 64-bit system? What could be the incompatibilities? I know this question is too vague. An example : I tried to setup FreeGlut 32-bit library with

Show Detail

Anaconda Python 32-bit is trying to load Anaconda 64-bit libraries

I'm on Window 7 64-bit and trying to use both Anaconda Python 64-bit and 32-bit distributions on the same system. I want to be able to build Windows 32-bit executables for distribution (with py2ex...

Show Detail