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