Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2004

Tip: Looking for answers? Try searching our database.

tlbimp.exe substitues coclass name for interface name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zhangrusi - 05 Oct 2004 22:19 GMT
I am using tlbimp.exe to create managed wrappers around some COM objects.  
Suppose I have an interface IFoo, and a second interface IBar whose methods
contain IFoo parameters.  I am finding that if I add a coclass, CFoo, that
implements IFoo, to my type library, tlbimp.exe replaces IFoo with CFoo in
IBar's method arguments.  Some code:

My IDL looks something like:

[
   object,
   uuid(...),
   dual,
   pointer_default(unique)
]
interface IFoo : IDispatch
{
   // properties, methods, etc.
};

[
   object,
   uuid(...),
   dual,
   pointer_default(unique)
]
interface IBar : IDispatch
{
   [id(1)] HRESULT DoSomething([in] IFoo* pFoo);
};

[
   uuid(...),
   version(1.0)
]
library Test
{
   importlib("stdole32.tlb");
   importlib("stdole2.tlb");

   [
       uuid(...)
   ]
   coclass CFoo
   {
       [default] interface IFoo;
   };
};

If I use tlbimp.exe to generate an interop assembly based on the resulting
type library, the prototype for IBar.DoSomething (as viewed in ildasm.exe)
will look like:

DoSomething : void(class TestLib.CFoo)

If I remove the coclass from the IDL, it will look like:

DoSomething : void(class TestLib.IFoo)

The second prototype is obviously what I want.  This seems like a bug in
tlbimp.exe--why should the presence of a coclass that uses a given interface
affect method prototypes in unrelated interfaces?  I have read through the
tlbimp.exe documentation and can't find any way to work around this behavior.
I have resorted to using awkward factory methods instead of coclasses for
the time being.  Can anyone comment on this?

Thanks...
Mattias Sj?gren - 06 Oct 2004 19:12 GMT
>This seems like a bug in tlbimp.exe

No it's by design.

If you don't like it you can add an additional dummy coclass to the
typelib that implements the same interface, or you can use ILDASM and
ILASM tp modify the generated interop assembly.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.