Re: Using same interfaces for in-proc vs. out-proc
Drew <dam@dam.com> wrote:
In this case the typelib is bound as a resource.
.... to which module?
Now, we have a ODL
for the EXE and an IDL for the DLL that are maintained seperately and
differ only by library name, "MyLibrary"(EXE) and "MyLibraryX"(DLL).
Also LIBID and all UDTs and interface/coclass GUIDs are different.
Your first message stated "all interfaces/UDTs have the same GUID". =
Which way is it?
// CSomeCollection
class ATL_NO_VTABLE CSomeCollection :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSomeCollection, &CLSID_Somes>,
#ifndef BUILDING_DLL
public IDispatchImpl<SomeColl::CollectionType,
&IID__IDualSomeCollection, &LIBID_MyLibrary, 2, 0>
#else
public IDispatchImpl<SomeColl::CollectionType,
&IID__IDualSomeCollection, &LIBID_MyLibraryX, 2, 0>
#endif
{
// ...
};
What is wanted, by someone who is very well versed in C++ but who I
don't think has much ATL/COM experience, is to use only the ODL or
IDL and have them differ only by LIBID so that we can somehow
templatize the creation of each interface to use the correct LIBID.
I suppose you could do that, with clever use of preprocessor. However, =
note that:
1) Defining two interfaces that are identical except for their IIDs =
(whether in the same or different type libraries) is pointless. It's not =
clear why you would ever want to do that. It'll just make your clients' =
lives difficult for no good reason.
2) Defining the same interface (with the same IID and everything) in two =
different type libraries (whether with different LIBIDs, or with the =
same LIBID but packaged two different ways) is a deployment nightmare. =
Imagine you install the EXE server and register its type library. This =
will point the registry entries for the interfaces mentioned in that =
type library to the EXE (see HKCR\Interface\{Your IID}). Later, you =
install the DLL, and it overwrites those entries and make them point to =
itself. Then you uninstall the DLL - it removes those registry entries, =
and your EXE stops working.
If you want to share the same interface definitions between two modules, =
build a standalone TLB file and treat it carefully as a shared resource =
for deployment purposes.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not =
necessarily a good idea. It is hard to be sure where they are going to =
land, and it could be dangerous sitting under them as they fly overhead. =
-- RFC 1925