C4772, even if the type library is registered and present

I have a set of Visual C ++ 9 COM component projects that are dependent on each other.

ComponentA publishes its typelib at ComponentA.tlb. ComponentB imports ComponentA.tlbinto ComponentB.idland publishes ComponentB.tlb. Signature methods in ComponentB.idlcontain parameters of types defined in ComponentA.tlb. ComponentA and ComponentB projects compiled.

ComponentC #importboth ComponentA.tlb, and ComponentB.tlbin stdafx.h- it will unexpectedly fail with

error C4772: #import referenced a type from a missing type library;

and then set

error C2440: 'return' : cannot convert from '__missing_type__ *' to '__missing_type__'

for wrappers using the types defined in ComponentA.tlb. This usually happens when it is ComponentA.tlbnot registered, but I'm sure I start it regtliband see in regedit that it is registered. ComponentA.tlbis present exactly on the path specified in the registry.

What is the source of the problem and how can I solve the problem?

+3
source share
2 answers

It seems that the problem may be due to a change in the ComponentA interfaces. As soon as ComponentA interfaces change while typelib is registered, a problem starts to arise.

The workaround I am using is to unregister ComponelA typelib and register it again - I created a small program (regtlib just cannot unregister typelib) that calls RegisterTypeLib()and UnregisterTypeLib(), and it looks like the problem is gone.

+1
source

, , , C4772 , .

A.tlb dir ( "$ (OutDir)\A.tlb." ) , .

#import A.tlb, B.tlb( A.tlb). #import of A.tlb , B.tlb . TLB include, .DLL regsvr32 ( , COM- ).

, #import ++, A.tlb, A.dll .

+2

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


All Articles