Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / January 2007



Tip: Looking for answers? Try searching our database.

COM Automation error - finding out which interface failed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike S - 25 Jan 2007 04:16 GMT
I posted to this group rather than microsoft.public.vb.com because this
group seems to be more active and I think that the API gurus here might
better appreciate the low-level hackery that I'm going to espouse near
the end.

Every now and then, I'll get "Object does not support Automation or
does not support expected interface" runtime error when running a VB6
app where I can't immediately determine the cause("Duh! I forgot to
register component X" or "Duh! I am referencing an older version of
X"). This is especially true in a large application I'm trying to
debug. The application is multi-tier, consisting of a "main" EXE and
various ActiveX DLL's and EXE servers. The application is a
records-management system - there is one ActiveX DLL that handles error
logging for every other EXE/DLL in the application, one DLL which
provides the low-level database access layer, and various DLL's (along
with one or two EXE servers throw in) which taken form an intermediate
abstraction layer between the main application and the database access
layer. In simpler, graphical terms:

To Database: Main application ---> Intermediate DLLs ---> DB Access
Layer ---> Database
>From Database: Database ---> DB Access Layer ---> Intermediate DLLs
---> Main application

The product is in it's 8th year, and in the beginning, it was
apparently straight-forward to debug, even though multiple EXEs and
DLLs were involved. Back then, if you wanted to debug A.dll, you could
just fire load the main app's VBP and A.VBP into the IDE, set a
breakpoint in A, start it up, and then start the main app. The VB6
debugger worked fine, breaking into A's code without a hitch, as anyone
would reasonably expect. These days, it ain't so simple. For example,
our database access layer is wrapped up in one DLL (it always has
been), but if want to break into code, loading the main app project and
the DB access layer project into the IDE and running no longer works. I
will say straight away that none of the components involved are
MTS/COM+ components (I hear the VB6 debugger doesn't always play nice
with COM+). Anyway, if I start up the DB access layer component in the
IDE, and then fire up the main app (in the same IDE or in another IDE
instance), it always blows up with an "Object does not support
Automation or does not support expected interface" runtime error. The
odd thing is that my code isn't directly causing the error, because
even with Break on All Errors set, the error actually pops up in a
standard message box. The caption is "VBDataViewWindow", but I'm not
sure if it's telling the truth (and anyway, I don't think it's worth
trying stepping into the VB6 runtime to figure out why my code is
breaking the Data View Window - trying to interpret COM-intensive code
in x86 assembly isn't my idea of a good time; I still think it's
strange). The application works fine outside of the IDE, so I suspect
it's indirectly related to the fact that, in the IDE, VB6DEBUG.DLL
impersonates any COM components also running in the IDE - I read
somewhere that when the debugger hosts a COM component in this way,
although the component still looks like an in-process server to the
outside world, it's actually running out-of-process, which can
apparently in rare cases hose things up because the debugger might not
be able to marshal all of the types that the component deals with.

My point with all this is simple: I assume that the VB6 Automation
error is what the IDE pops ups whenever a QueryInterface call returns
E_NOINTERFACE. So, my question is, is there any (fairly
straightforward) way to figure out what the VB6's last call to
QueryInterface looked like, so that I can figure out what interface it
was trying to get at. I suspect the missing interface is IMarshal, but
that's only a wild guess since I'm not too familiar with the ins and
outs of COM marshalling.

I was thinking I could write a VB6 add-in to do this, but it would
pretty hackish, because I would have to cheat by finding VB6's IUnknown
vtable (I believe the same one is shared by all VB6 components in a
given process), pointing QueryInterface to my own custom version,
logging the parameters I receive to a window, and then calling the
original QueryInterface function. In essence, the add-in would generate
a history of all the QueryInterface calls up to the point where I get
an Automation error. Then it would be pretty safe to assume the most
recent call was the one that failed and based on the IID parameter
passed to that call I can at least put a name on the interface and
(maybe) get a better idea of what the heck is going on. I'm wondering
if that makes sense or if anyone has encountered similar spurious
errors apparently coming from VBDataViewWindow when debugging multiple
components in the IDE (the add-in code runs great in my head, but
haven't tried it out yet ;-)

---
Mike S
Tony Proctor - 25 Jan 2007 15:03 GMT
I can't think of any reason why you would no longer be able to co-host the
main EXE and DB accessed DLL in the same IDE Mike -- we do that all the time
here, including for COM+ components, MMC snap-ins, SQL DTS tasks, DLLs
invoked from ASP, etc (i.e. lots of variations). The IDE cannot debug
multi-threaded code (it always forced it to execute single-threaded) but
otherwise it's pretty solid.

Re-reading your (long-) post make me wonder if your registry needs cleaning.
I would take a look with the OLE viewer tool, or even RegEdit, and see if
you have multiple entries for the same VB classes, Interfaces, or Typelibs.
Are your projects set to 'project compatibility'? That's recommended if
you're debugging VB 'groups' in the IDE.

   Tony Proctor

> I posted to this group rather than microsoft.public.vb.com because this
> group seems to be more active and I think that the API gurus here might
[quoted text clipped - 79 lines]
> ---
> Mike S
Mike S - 26 Jan 2007 01:53 GMT
On Jan 25, 10:03 am, "Tony Proctor"
<tony_proctor@aimtechnology_NoMoreSPAM_.com> wrote:
> I can't think of any reason why you would no longer be able to co-host the
> main EXE and DB accessed DLL in the same IDE Mike

Neither can I, hence the post ;-)

> Re-reading your (long-) post make me wonder if your registry needs cleaning.

I did go off on quite a few detours in my post, sorry about that -- I
had a lot of loosely-related topics on my mind.

> Are your projects set to 'project compatibility'? That's recommended if
> you're debugging VB 'groups' in the IDE.

Yep. And VB changes all the project references to point to the VBP
files (as well as making the correct changes to the registry -- i.e.
making VB6DEBUG.DLL the server for all the hosted components). That's
why the automation error is so strange and what got me off on the
tangent of wanting to find out what interface on what object VB was
suddenly trying to acquire in the debug environment and couldn't. The
IDE dev team really could've make that error message a bit more
descriptive-- if VB does a QueryInterface for an interface
SomeInterface and it fails, I don't see why the IDE's error handling
couldn't have been made to be more specific, at least when VB6
components are involved: "An object of class Whatever doesn't support
the interface SomeInterface."

Anyway, the *really* weird part is the Automation error message pops up
in a "VBDataViewWindow" message box, not the IDE's run-time error
dialog, so somehow the Data View feature of the IDE is involved or else
it's a red herring....If I run outside the IDE, everything works fine,
so...well...yeah...I've already mentioned that this whole thing is
strange ;-)
--
Mike S
 
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



©2009 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.