Problems with the # import.NET server out of turn

In a C ++ program, I am trying to #import TLB server out-of-proc.NET.

I get errors like:

z: \ server.tlh (111): error C2146: syntax error: missing ';' before the identifier 'GetType'

z: \ server.tlh (111): error C2501: '_TypePtr': missing storage class or type specifiers

z: \ server.tli (74): error C2143: syntax error: missing ';' before 'tag :: id'

z: \ server.tli (74): error C2433: '_TypePtr': 'inline' is not allowed for data declarations

z: \ server.tli (74): error C2501: '_TypePtr': missing storage class or type specifiers

z: \ server.tli (74): fatal error C1004: an unexpected end to the found file was found

TLH is as follows:

_bstr_t GetToString();
VARIANT_BOOL Equals (const _variant_t & obj);
long GetHashCode();
_TypePtr GetType();
long Open();

, . .NET, GetType(), Equals() .. GetType(), , .

google , #import mscorlib.tlb ( ), .

?

+3
5

no_namespace raw_interfaces_only #import:

#import "server.tlb" no_namespace named_guids

TLBEXP.EXE REGASM.EXE .

+1
#import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" was the solution for me.
+3

, vs tlb : // #import "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.tlb" StdAfx.h #inport youOwn.tlb , _Type, _ObjRef -

, .

: , , , Ptr

?

+1
source

It seems you need to use

[ClassInterface(ClassInterfaceType.None)]

Here is another discussion about a similar issue.

+1
source

Also, make sure your C # class does not have this attribute:

[ClassInterface (ClassInterfaceType.AutoDual)] & ​​lt; - It seems to cause errors in C ++ with _TypePtr

0
source

Source: https://habr.com/ru/post/1696423/


All Articles