mysterious DISP_E_UNKNOWNNAME (only default interface?) 
Author Message
 mysterious DISP_E_UNKNOWNNAME (only default interface?)

Quote:

>Here is a brief description of the problem:

>Platform NT Workstation 4.0
>Development Environment VC++ Studio 5.0 (Enterprise version)

>I created an ATL object with two dual interfaces Itest2 and Itest3
>with one of them marked "default". Itest2 has a method called
>setValue() and Itest3 has a method called getValue().
>I have a C++ MFC client, from where I call QueryInterface() with
>IID_IDispatch as an argument on both the interfaces. This call
>succeeds. After that, GetIDsOfNames() succeeds only for "setValue"
>(which is the name of the method in the default interface) and not for
>"getValue" (which is the name of the method in the non-default
>interface). The error code I get is DISP_E_UNKNOWNNAME

>Does it mean that I can only get the default interface from my C++ or
>VB client and not the other one? What's going on here?

Well, when you have multiple IDispatch-based interfaces on an object, only
one of them can be returned by a QI for IID_IDispatch - and it better be the
same one every time.  That's what the [default] attribute tells the MIDL
compiler.
If you want to get the Itest3 interface, you have to QI specifically for
IID_Itest3.  Then you can call get_Value.  That's why most objects only
provide one IDispatch-based interface; it's less of a headache.  There's no
general reason(though you might have a specific one) to have multiple
dispinterfaces in the first place.
--
John C. Barstow
Microcrafts, Inc.
http://www.*-*-*.com/
425-250-0000


Tue, 25 Jul 2000 03:00:00 GMT  
 mysterious DISP_E_UNKNOWNNAME (only default interface?)

What doesn't make sense below is "from where I call QueryInterface() with
IID_IDispatch as an argument on both the interfaces." Querying the component
for IID_IDispatch will retrieve the same interface every time, and your ATL
component has an entry in its COM map for IID_IDispatch; it should resolve
to the default interface. The interface through which you make the
QueryInterface call is immaterial.

In order to get hold of your other, non default dual interface you must
query for it by its unique interface id, something like IID_IFoo and not
IID_IDispatch. This can be accomplished from VC++ as well as VB clients. VB
clients will need to Dim a variable as the IFoo type, available via your
type library.

--
________________________________________________________________

Ray Brown                       Home: (612) 892-7329
Lawson Software                 Office: (612) 379-8086 x4393
1300 Godward Street             Fax: (612) 379-8512

________________________________________________________________

Quote:

>Here is a brief description of the problem:

>Platform NT Workstation 4.0
>Development Environment VC++ Studio 5.0 (Enterprise version)

>I created an ATL object with two dual interfaces Itest2 and Itest3
>with one of them marked "default". Itest2 has a method called
>setValue() and Itest3 has a method called getValue().
>I have a C++ MFC client, from where I call QueryInterface() with
>IID_IDispatch as an argument on both the interfaces. This call
>succeeds. After that, GetIDsOfNames() succeeds only for "setValue"
>(which is the name of the method in the default interface) and not for
>"getValue" (which is the name of the method in the non-default
>interface). The error code I get is DISP_E_UNKNOWNNAME

>Does it mean that I can only get the default interface from my C++ or
>VB client and not the other one? What's going on here?



Wed, 26 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. can't call script function in MSHTML hr=DISP_E_UNKNOWNNAME

2. DISP_E_UNKNOWNNAME from GetIDsOfNames

3. DISP_E_UNKNOWNNAME from GetIDsOfNames

4. DISP_E_UNKNOWNNAME from GetIDsOfNames

5. Default accessibility for interface

6. Can Default Values be implemented in IDIspatch interface

7. the default interface

8. Default param values thru interfaces

9. Addressing secondary (non-default) interfaces

10. COM IDL - How to see Defaults of Interface parameters

11. Need Default values for Interface Parameters ....

12. getting ip address of the default route interface (public ip vs private ip)

 

 
Powered by phpBB® Forum Software