I have a .Net asm with several interfaces and classes exposed to COM using the [ComVisible(true)] attribute. I generate a tlb, then reference this in my StdAdx file within a C++ COM component. What's odd is that for some reason, even though the very basic intellisense (VS6 for C++) is able to see my properties and methods, I get compiler errors stating that they are not a member. For example:
[Guid("88E58BE4-E0CB-4d1b-9553-A5431E7A0BEA")]
[ComVisible(true)]
public interface ISupplierPayment : IBusinessObjectPersist
{
String Comment
{
get;
set;
}
And in the generated tlh in c++:
struct __declspec(uuid("e94bd31e-327c-33c8-8a55-b693ccf1ed96"))
struct __declspec(uuid("e94bd31e-327c-33c8-8a55-b693ccf1ed96"))
ISupplierPayment : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall get_Comment (
BSTR * pRetVal ) = 0;
And finally the error when trying to use this in code:
D:\MR...File.cpp(647) : error C2039: 'Comment' : is not a member of 'ISupplierPayment' d:\mr...projectdir\release\TheDotNetClasses.tlh(758) : see declaration of 'ISupplierPayment'
Any ideas what I should look at next? if it's in the tlh and intellisense recognises it and it's there in OLEView on the tlb, I'm not sure what could possibly be wrong.. thanks in advance for taking a look
UPDATE Further example of related issue: C#
[Guid("3BE93D52-86B7-42e6-BAE6-29037F6BC9C4")]
[ComVisible(true)]
public interface IDataStoreFactory
{
void TestMethod(String test);
C++ TLH
struct __declspec(uuid("3be93d52-86b7-42e6-bae6-29037f6bc9c4"))
IDataStoreFactory : IDispatch
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall TestMethod (
BSTR dataStoreAssembly ) = 0;
void TestMethod(String test);
C++ method call
spDataStoreFactory->TestMethod("test");
C++ compile error
'TestMethod' : cannot convert parameter 1 from 'char [5]' to 'unsigned short *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Huh!? it's not a short it's a BSTR... very confused now