[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

tlbimp importing COM interface params as if they were locally defi

Sean Hokanson

11/6/2007 6:46:00 PM

I have an .idl file that defines an interface with a method that takes
another (externally-defined) interface pointer as a parameter (see example
tmp.idl file below, where ITmp::DOM takes an IXMLDOMDocument pointer). When I
run midl.exe to generate the .tlb, then run tlbimp.exe on that .tlb, the
produced interop assembly includes the externally-defined interface in its
own namespace. For example, using the sample tmp.idl file below and doing the
following (using VS2005 tools):

> midl tmp.idl
> tlbimp tmp.tlb /out:tmp.wrapper.dll
> ildasm tmp.wrapper.dll

ildasm shows that the assembly includes a bunch of the MSXML types and
interfaces in the tmp.wrapper namespace. Is there a way to prevent this so
the assembly only includes the types "locally" defined? The reason I ask is
because when we use this assembly in a C# project that also references the
assembly that actually defines those types (in this case, msxml via its own
interop assembly), we end up having to cast IXMLDOMDocument (and other)
variables back and forth between the namespaces, even though they are
actually the same type.

Using the /reference or /tlbreference switches on tlbimp have no effect.

I'm happy to provide more info if needed.

// ***** tmp.idl file ***********
import "ocidl.idl";
[
object,
uuid(897212B0-ECBB-11D4-B6C4-0090277BEE17),
pointer_default(unique)
]
interface ITmp : IUnknown
{
[propput] HRESULT DOM([in] IXMLDOMDocument* pIXMLDOMDocument);
};
[
uuid(7FD845E9-EB24-11D4-B6C3-0090277BEE17),
version(1.0)
]
library TMPLib
{
[
uuid(897212B1-ECBB-11D4-B6C4-0090277BEE17)
]
coclass Tmp
{
[default] interface ITmp;
};
};

1 Answer

(Mattias Sjögren)

11/6/2007 7:35:00 PM

0

Sean,

>Is there a way to prevent this so
>the assembly only includes the types "locally" defined?

Yes, replace the

import "ocidl.idl"

statement with

importlib("msxml6.dll");

or whatever version of the MSXML typelib you want to reference. The
importlib statement must go inside your library block.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.