ATL, importlib attribute, library attribute, ADO 
Author Message
 ATL, importlib attribute, library attribute, ADO

Trying (in vain) to create an interface that returns an ADO recordset.  The
code itself appears to be fine -- I have the required import statements in
my header file and everything compiles.  However, the process comes to a
screeching halt when VC++ generates and then tries to compile the IDL file.
The problem appears to be that the MIDL importlib statement in the library
block is always generated after all the interface definitions.  I haven't
found a way to control this behavior or to solve this problem.  Any
suggestions?

Here is an example interface in an attributed ATL project:

[
    object,
    uuid("FC09FAC0-11DB-4AA6-ACBA-7C20181C36CE"),
    dual, helpstring("IDataGateway Interface"),
    pointer_default(unique)
]
__interface IDataGateway : IDispatch
{
   [id(1), helpstring("method Find")]
   HRESULT Find([in] LONG nID, [out,retval] ADODB::_Recordset** ppRs);

Quote:
}

The compilation always fails with this:
LINK : fatal error LNK1240: failed to compile IDL content
c:\datagateway.h(17): error MIDL2011 : unresolved type declaration :
_Recordset [ Parameter 'ppRs' of Procedure 'Find' ( Interface
'IDataGateway' ) ]

The module attribute looks like this:
[
    module(dll, uuid = "{70B8C941-FED0-483D-8E4A-846E2A0E2B4F}",
    name = "Test",
    helpstring = "Test 1.0 Type Library",
    resource_name = "IDR_TEST"),
    importlib("c:\\program files\\common files\\system\\ado\\msado15.dll")
];

The resulting IDL file snippet always generates the library block (and the
importlib directive) *after* all the custom interfaces.  I am *assuming*
that is the cause of the problem but I am a real newbie to COM development
so I could be way off.  If this is the cause of the problem, is there any
way to force the library block and its importlib statement to the top of the
IDL file??

Thanks for any suggestions.



Wed, 05 Jan 2005 06:46:03 GMT  
 ATL, importlib attribute, library attribute, ADO
call importlib("c:\\program files\\common files\\system\\ado\\msado15.dll")
after library keyword, after importlib("stdole32.tlb")...

Mike

Quote:

> Trying (in vain) to create an interface that returns an ADO recordset.
The
> code itself appears to be fine -- I have the required import statements in
> my header file and everything compiles.  However, the process comes to a
> screeching halt when VC++ generates and then tries to compile the IDL
file.
> The problem appears to be that the MIDL importlib statement in the library
> block is always generated after all the interface definitions.  I haven't
> found a way to control this behavior or to solve this problem.  Any
> suggestions?

> Here is an example interface in an attributed ATL project:

> [
>     object,
>     uuid("FC09FAC0-11DB-4AA6-ACBA-7C20181C36CE"),
>     dual, helpstring("IDataGateway Interface"),
>     pointer_default(unique)
> ]
> __interface IDataGateway : IDispatch
> {
>    [id(1), helpstring("method Find")]
>    HRESULT Find([in] LONG nID, [out,retval] ADODB::_Recordset** ppRs);
> }

> The compilation always fails with this:
> LINK : fatal error LNK1240: failed to compile IDL content
> c:\datagateway.h(17): error MIDL2011 : unresolved type declaration :
> _Recordset [ Parameter 'ppRs' of Procedure 'Find' ( Interface
> 'IDataGateway' ) ]

> The module attribute looks like this:
> [
>     module(dll, uuid = "{70B8C941-FED0-483D-8E4A-846E2A0E2B4F}",
>     name = "Test",
>     helpstring = "Test 1.0 Type Library",
>     resource_name = "IDR_TEST"),
>     importlib("c:\\program files\\common files\\system\\ado\\msado15.dll")
> ];

> The resulting IDL file snippet always generates the library block (and the
> importlib directive) *after* all the custom interfaces.  I am *assuming*
> that is the cause of the problem but I am a real newbie to COM development
> so I could be way off.  If this is the cause of the problem, is there any
> way to force the library block and its importlib statement to the top of
the
> IDL file??

> Thanks for any suggestions.



Wed, 05 Jan 2005 18:25:23 GMT  
 ATL, importlib attribute, library attribute, ADO
Unfortunately, that is what I am doing.  This appears to
be a general issue with attributed ATL as opposed to an
ADO specific issue.  The general problem appears to be
this: the library block is placed *after* the interface
declarations in the VS.NET generated IDL file as opposed
to *before* the interface declarations.  Since importlib
statements must be in the library block and the library
block is placed after the interface declarations -- well,
anytime you want to reference a type in your interface the
generated IDL will not compile.  I am probably missing
something since I am new to this but it is frustrating.

Quote:
>-----Original Message-----
>call importlib("c:\\program files\\common

files\\system\\ado\\msado15.dll")
Quote:
>after library keyword, after importlib("stdole32.tlb")...

>Mike




Quote:
>> Trying (in vain) to create an interface that returns an
ADO recordset.
>The
>> code itself appears to be fine -- I have the required

import statements in
Quote:
>> my header file and everything compiles.  However, the
process comes to a
>> screeching halt when VC++ generates and then tries to
compile the IDL
>file.
>> The problem appears to be that the MIDL importlib

statement in the library
Quote:
>> block is always generated after all the interface

definitions.  I haven't
Quote:
>> found a way to control this behavior or to solve this
problem.  Any
>> suggestions?

>> Here is an example interface in an attributed ATL
project:

>> [
>>     object,
>>     uuid("FC09FAC0-11DB-4AA6-ACBA-7C20181C36CE"),
>>     dual, helpstring("IDataGateway Interface"),
>>     pointer_default(unique)
>> ]
>> __interface IDataGateway : IDispatch
>> {
>>    [id(1), helpstring("method Find")]
>>    HRESULT Find([in] LONG nID, [out,retval]

ADODB::_Recordset** ppRs);

- Show quoted text -

Quote:
>> }

>> The compilation always fails with this:
>> LINK : fatal error LNK1240: failed to compile IDL
content
>> c:\datagateway.h(17): error MIDL2011 : unresolved type
declaration :
>> _Recordset [ Parameter 'ppRs' of Procedure 'Find' (
Interface
>> 'IDataGateway' ) ]

>> The module attribute looks like this:
>> [
>>     module(dll, uuid = "{70B8C941-FED0-483D-8E4A-
846E2A0E2B4F}",
>>     name = "Test",
>>     helpstring = "Test 1.0 Type Library",
>>     resource_name = "IDR_TEST"),
>>     importlib("c:\\program files\\common

files\\system\\ado\\msado15.dll")
Quote:
>> ];

>> The resulting IDL file snippet always generates the

library block (and the
Quote:
>> importlib directive) *after* all the custom

interfaces.  I am *assuming*
Quote:
>> that is the cause of the problem but I am a real newbie
to COM development
>> so I could be way off.  If this is the cause of the

problem, is there any
Quote:
>> way to force the library block and its importlib

statement to the top of

- Show quoted text -

Quote:
>the
>> IDL file??

>> Thanks for any suggestions.

>.



Fri, 07 Jan 2005 01:06:46 GMT  
 ATL, importlib attribute, library attribute, ADO
For those having the same problem, here is the fix that was found:

1) add the common ADO dir to your additional include directories:
"C:\Program Files\Common Files\System\ADO"

2) add the following to the top of your include:

#import <msado15.dll> no_namespace no_implementation named_guids \
rename("EOF", "adoEOF") rename("Recordset", "adoRecordset")

[idl_quote (import "msado15.idl";)];

Quote:

> Trying (in vain) to create an interface that returns an ADO recordset.
The
> code itself appears to be fine -- I have the required import statements in
> my header file and everything compiles.  However, the process comes to a
> screeching halt when VC++ generates and then tries to compile the IDL
file.
> The problem appears to be that the MIDL importlib statement in the library
> block is always generated after all the interface definitions.  I haven't
> found a way to control this behavior or to solve this problem.  Any
> suggestions?

> Here is an example interface in an attributed ATL project:

> [
>     object,
>     uuid("FC09FAC0-11DB-4AA6-ACBA-7C20181C36CE"),
>     dual, helpstring("IDataGateway Interface"),
>     pointer_default(unique)
> ]
> __interface IDataGateway : IDispatch
> {
>    [id(1), helpstring("method Find")]
>    HRESULT Find([in] LONG nID, [out,retval] ADODB::_Recordset** ppRs);
> }

> The compilation always fails with this:
> LINK : fatal error LNK1240: failed to compile IDL content
> c:\datagateway.h(17): error MIDL2011 : unresolved type declaration :
> _Recordset [ Parameter 'ppRs' of Procedure 'Find' ( Interface
> 'IDataGateway' ) ]

> The module attribute looks like this:
> [
>     module(dll, uuid = "{70B8C941-FED0-483D-8E4A-846E2A0E2B4F}",
>     name = "Test",
>     helpstring = "Test 1.0 Type Library",
>     resource_name = "IDR_TEST"),
>     importlib("c:\\program files\\common files\\system\\ado\\msado15.dll")
> ];

> The resulting IDL file snippet always generates the library block (and the
> importlib directive) *after* all the custom interfaces.  I am *assuming*
> that is the cause of the problem but I am a real newbie to COM development
> so I could be way off.  If this is the cause of the problem, is there any
> way to force the library block and its importlib statement to the top of
the
> IDL file??

> Thanks for any suggestions.



Fri, 07 Jan 2005 21:51:21 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to get the type-library GUID in an attributed ATL project

2. Attributed and non-attributed code performance

3. Retriving attribute from custom attribute collection

4. Creating custom attribute in assembly and accessing attribute from different project

5. ADO Interface params in attributed project (VC7)

6. ADO, setting field/column attributes?

7. How to retrieve all attributes from LDAP server using ADO

8. ATL VC7 attributes and #define

9. Attributed ATL and CoClass naming

10. ATL Attribute Problem

11. VC++ 7 ATL (attributed) object blocks on __raise if client unsubscribes

12. Attributed ATL: [export] problems

 

 
Powered by phpBB® Forum Software