Re: Using same interfaces for in-proc vs. out-proc
Drew <dam@dam.com> wrote:
In your situation, with two coclasses sharing a set of interfaces, I
can suggest two approaches. One is a single type library with two
coclass blocks:
library {
[dual]
interface IMySharedInterface : IDispatch {...};
coclass MyInProcServer {
[default] interface IMySharedInterface;
};
coclass MyOutOfProcServer {
[default] interface IMySharedInterface;
};
}
--------------
It seems that in this case, there can only be one COM server
registered at a time
What makes you think so?
and that neither is prevented from using either
of the coclasses (MyInProcServer, MyOutOfProcServer).
I don't understand what you mean by "using a coclass".
So what's the
point? I need both in-proc and out-of-proc to be registered at the
same time and be distinguishable from one another.
The example above won't preclude that.
The single type library in the first case, and the shared type
library in the second, would be packaged as a standalone TLB file...
-----------------
Could you elaborate on this? I've attempted this approach but end up
with shared.tlb being something like 500k and in-proc/out-of-proc.tlb
being about 3k.
Why is that surprising? They only contain the coclass and the reference =
to the shared TLB.
Here's my out-of-proc idl:
[ uuid("SOME-GUID-HERE"), version(1.0),
helpstring("MyApplication 1.0 Object Library") ]
library MyAppLibrary
{
importlib("shared.tlb");
interface _IDualMyApp;
This declaration shouldn't be necessary.
[
uuid("SOME-GUID-HERE"),
version(1.0),
helpstring("Global Application Object"),
appobject
]
coclass Application
{
[default] interface _IDualMyApp;
};
};
for in-proc idl:
[ uuid(SOME-DIFFERENT-GUID-HERE), version(1.0),
helpstring("MyDLL 1.0 Object Library") ]
library MyAppLibraryX
{
importlib("shared.tlb");
interface _IDualMyApp;
[
uuid(SOME-DIFFERENT-GUID-HERE),
version(1.0),
helpstring("Global Application Object"),
appobject
]
coclass Application
{
[default] interface _IDualMyApp;
};
};
All other interfaces (including _IDualMyApp), coclasses, UDTs, enums,
etc. are in the shared.tlb. The .idl files compile fine but when I
compile my C++ code, none of them are recognized, giving 3000+
errors.
Are you using #import in your C++ code? Unfortunately, #import doesn't =
automatically follow references between TLBs. You'll have to #import =
"shared.tlb" explicitly.
I assume this is where the "would be packaged as a standalone
TLB file" comes in. So how do I go about doing that?
When you compile shared.idl, a file named shared.tlb is produced.
--
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