Why can't I browse dll to figure what's in

2019-07-31 17:52发布

问题:

I'm looking for a missing COM interface X which I suspect is defined in Y.dll. I can peek at this presumptive interface using

grep X Y.dll

which says "matches". Hurrah, suspicion confirmed!

Alas, when I use the Object Browser in Visual Studio Express, trying to add Y.dll to my Custom Component Set, I get the error: "Some components could not be browsed" in a pop-up window.

So what are the reasons I can't browse this dll? Can the COM interfaces deliberately or accidentally be protected, hidden, secured, or obscured? Obviously I need a primer!

Officially, all Microsoft knows about this seems to be generally devoid of insight:

This error generally occurs when you attempt to add a file type that does not support object browsing, such as .htm and .txt files, in the Component Selector dialog box. The Object Browser supports file types such as .bsc, .olb, .tlb, .dll, .exe, and .ocx.

Seriously, what are the reasons for a dll or exe to not support object browsing? Any pointers to tutorials or books would be appreciated by this beginner! Thanks.

回答1:

COM Object browsers rely on metadata (type libraries) exported by COM servers (dll, exe, ocx, etc).

The problem is that COM Servers are not required to export any metadata about which interfaces it implements. Unfortunately I have found quite a number of such servers (so one needs to know which CoClasses, Interfaces, etc are supported by other means).

Check if your COM Server (y.dll) contains a resource called "TYPELIB" similar to:

Hope this helps.