TLB and declarations 
Author Message
 TLB and declarations

I'm sure this one is an easy one for those of you that
know how to.

If I use a TLB (generated from a C# or vb .net dll and
imported using the #import directive) to reference an
interface I've created I can perform the following in code:
IMyInterfacePtr m_Temp(CLSID_MyClass);

This allows my to instantiate my class correctly - so far,
so good.  The problem I have is when I want m_Temp to be
declared at a different scope.  If I put m_Temp into my
header file I cannot determine what type I need to
assign.  My code is:
protected:
   IMyInterface m_Temp;

...which doesn't work - any help will be much appreciated.



Sat, 21 May 2005 01:38:41 GMT  
 TLB and declarations
Steven,
I not sure I fully understood your question.

You can split this into to steps:
IMyInterfacePtr m_Temp; //class definition
m_Temp.CreateInstance(CLSID_MyClass); // call from initilialization code

If this doesn't  help, please explain in a bit more detail the nature of
your problem.

Hope this helps.

Thank you,
Bobby Mattappally
Microsoft VC++/C# Team

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:
>Content-Class: urn:content-classes:message


>Subject: TLB and declarations
>Date: Mon, 2 Dec 2002 09:38:41 -0800

>I'm sure this one is an easy one for those of you that
>know how to.

>If I use a TLB (generated from a c# or vb .net dll and
>imported using the #import directive) to reference an
>interface I've created I can perform the following in code:
>IMyInterfacePtr m_Temp(CLSID_MyClass);

>This allows my to instantiate my class correctly - so far,
>so good.  The problem I have is when I want m_Temp to be
>declared at a different scope.  If I put m_Temp into my
>header file I cannot determine what type I need to
>assign.  My code is:
>protected:
>   IMyInterface m_Temp;

>...which doesn't work - any help will be much appreciated.



Sat, 21 May 2005 09:27:30 GMT  
 TLB and declarations
In order to use m_Temp within the scope og the current
class I need to define it in xxx.h.  It is this
declaration that is causing me problems - If I define it
at module level use it and throw it away, all is fine.

I need to be able to access this variable throughout my
class.  I recieve a variety of errors, namely C2146.  As
far as I understand, this is caused by the compiler not
understanding IMyInterface.

Many thanks
Steve

Quote:
>-----Original Message-----
>Steven,
>I not sure I fully understood your question.

>You can split this into to steps:
>IMyInterfacePtr m_Temp; //class definition
>m_Temp.CreateInstance(CLSID_MyClass); // call from

initilialization code
Quote:

>If this doesn't  help, please explain in a bit more

detail the nature of
Quote:
>your problem.

>Hope this helps.

>Thank you,
>Bobby Mattappally
>Microsoft VC++/C# Team

>This posting is provided "AS IS" with no warranties, and
confers no rights.

>--------------------
>>Content-Class: urn:content-classes:message


>>Subject: TLB and declarations
>>Date: Mon, 2 Dec 2002 09:38:41 -0800

>>I'm sure this one is an easy one for those of you that
>>know how to.

>>If I use a TLB (generated from a c# or vb .net dll and
>>imported using the #import directive) to reference an
>>interface I've created I can perform the following in
code:
>>IMyInterfacePtr m_Temp(CLSID_MyClass);

>>This allows my to instantiate my class correctly - so
far,
>>so good.  The problem I have is when I want m_Temp to be
>>declared at a different scope.  If I put m_Temp into my
>>header file I cannot determine what type I need to
>>assign.  My code is:
>>protected:
>>   IMyInterface m_Temp;

>>...which doesn't work - any help will be much
appreciated.

>.



Sat, 21 May 2005 18:07:32 GMT  
 TLB and declarations
Steve,
Put the #import statement before class the declaration in the header file.
Also watch out for the namespaces, by default #import puts the declarations
in a namespace.
You can use no_namespace option to the override this.
Please see the generated tlh and tli file.

If this doesn't help, post some code or send me (remove "online." from id)
a repro project and I can take a look.

Hope this helps.

Thank you,
Bobby Mattappally
Microsoft VC++/C# Team

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:
>Content-Class: urn:content-classes:message





Quote:
>Subject: RE: TLB and declarations

>In order to use m_Temp within the scope og the current
>class I need to define it in xxx.h.  It is this
>declaration that is causing me problems - If I define it
>at module level use it and throw it away, all is fine.

>I need to be able to access this variable throughout my
>class.  I recieve a variety of errors, namely C2146.  As
>far as I understand, this is caused by the compiler not
>understanding IMyInterface.

>Many thanks
>Steve

>>-----Original Message-----
>>Steven,
>>I not sure I fully understood your question.

>>You can split this into to steps:
>>IMyInterfacePtr m_Temp; //class definition
>>m_Temp.CreateInstance(CLSID_MyClass); // call from
>initilialization code

>>If this doesn't  help, please explain in a bit more
>detail the nature of
>>your problem.

>>Hope this helps.

>>Thank you,
>>Bobby Mattappally
>>Microsoft VC++/C# Team

>>This posting is provided "AS IS" with no warranties, and
>confers no rights.

>>--------------------
>>>Content-Class: urn:content-classes:message


>>>Subject: TLB and declarations
>>>Date: Mon, 2 Dec 2002 09:38:41 -0800

>>>I'm sure this one is an easy one for those of you that
>>>know how to.

>>>If I use a TLB (generated from a c# or vb .net dll and
>>>imported using the #import directive) to reference an
>>>interface I've created I can perform the following in
>code:
>>>IMyInterfacePtr m_Temp(CLSID_MyClass);

>>>This allows my to instantiate my class correctly - so
>far,
>>>so good.  The problem I have is when I want m_Temp to be
>>>declared at a different scope.  If I put m_Temp into my
>>>header file I cannot determine what type I need to
>>>assign.  My code is:
>>>protected:
>>>   IMyInterface m_Temp;

>>>...which doesn't work - any help will be much
>appreciated.

>>.



Sun, 22 May 2005 01:35:38 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Adding a tlb to anther tlb

2. defining declarations vs. referencing declarations

3. C Declaration --> VB Declaration

4. dotnet MIDL compiler fails to generate .tlb for DownloadMgr.idl

5. #import with EMBEDDED_IDL results in all types in my own tlb

6. Importing mscolib.tlb

7. A strange problem with importing TLB

8. Howto Import com dll referencing a tlb?

9. VC++ 6 can't load tlb-file from tlbexp-tool

10. how to convert helpstring to tlb: using .net componet from COM programs

11. How to solve circular dependency of TLB file

12. *.tlb

 

 
Powered by phpBB® Forum Software