Any way to resolve C4772 errors without registering a DLL?

I support the VS2010 project, which has several cross-referenced COM libraries. I am trying to configure a project so that it is created on a random workstation where VS2010 is installed. The workstation can be either 32 or 64 bits, so if I set the project to "register output", the assembly will not be able to build a 32-bit machine, since the 64-bit DLL will not be available for download to call DllRegisterServer.

Here is an example: Typelib from project B refers to typelib from project A. Project C will refer to project B using the following statement:

#import "B.tlb"

Since library B references A when B.tlb is imported, the compiler tries to load types from A. So, if A is not registered, compilation will end with:

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

I tried to open B.tlb using the OleView application, and it is sure that the devil knows only the file name for the library. Link if registered with regsvr32.

So my question here is: is there an alternative way for library references to resolve themselves correctly, without having to register a TLB, simply placing all the files in the same directory or binding some kind of manifest? For example, rename the TLB for the library as .tlb or something like that.

+3
source share
3 answers

A.tlb B.tlb include().

# import , , .

+2

: .tlb V++ → PATH, . : http://msdn.microsoft.com/en-us/library/sce74ah7.aspx .tlb PATH LIB.

+2

The easiest way to place all * .tlb files in a directory when they are used.

Depends on the configuration of your project. Copy all * .tlb files to: $ (OutDir), $ (ProjectDir), where the C # import file is, dir when creating * .tlb, etc.

Regards, Mariusz

+1
source

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


All Articles