Anonymous302

I am trying to call a C# component developed by an external firm from C++.

I imported the type library provided to me.

When I try to compile using MSVC 6.0 compiler , I get the following error.

error C2146: syntax error : missing ';' before identifier 'GetType'
error C2501: '_TypePtr' : missing storage-class or type specifiers
error C2143: syntax error : missing ';' before 'tag::id'
error C2433: '_TypePtr' : 'inline' not permitted on data declarations
error C2501: '_TypePtr' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found.

Any information will be highly appreciated.

Thank you




Re: Visual C++ Language Calling a C# component from C++

Holger Grund

#import isn't particulary sophisticated. The compiler frontend simply reads the type library and emits code for it (the .tlh and depending on the import attributes the .tli files).

After that everything is done as usual. You can still preprocess the code to remove any macro interference.

Just take a look at the (possibly compiler-generated) source code for the first error. How does the last thing before it look like And how does the line with error look like

-hg





Re: Visual C++ Language Calling a C# component from C++

Novozh

Try using your #import instruction with "raw_interfaces_only", as in:

#import "YourTypeLibrary.tlb" raw_interfaces_only





Re: Visual C++ Language Calling a C# component from C++

Anonymous302

Thanks for the tip.. That helped in getting the type library compiled, however it now has issues with the function call

foo.CPP(107) : error C2660: 'myComFunction' : function does not take 4 parameters

so I changed the call to take a 5th parameter which I saw as a part of the function signature in the .tlh file.

When the CoCreateInstance is called the HRESULT returned is -2147024894 which is 0x80070002.

This translates to "0x80070002. the system cannot find the file specified"..

Is there anyway I can trace what is happening when the CoCreateInstance is called

Thanks again.