任何方式来解决C4772错误,而无需注册DLL? [英] Any way to resolve C4772 errors without having to register DLLs?

查看:213
本文介绍了任何方式来解决C4772错误,而无需注册DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护一个VS2010项目,它有一些交叉引用的COM库。我试图配置项目的方式,它是可以从一个随机工作站可以构建VS2010安装。工作站可以是32位和64位,因此如果我将项目配置为寄存器输出,构建将无法构建在32位机器上,因为64位DLL将无法加载到调用DllRegisterServer。 p>

下面是一个例子:项目B中的Typelib从项目A引用了typelib。项目C将通过以下语句引用项目B:

  #importB.tlb

B引用A,当B.tlb被导入时,编译器尝试从A加载类型。所以,如果A未注册,编译将失败:

 错误C4772:#import引用了一个缺少类型库的类型... 


$ b b

我试图使用OleView应用程序打开B.tlb,并且它确定如果它使用regsvr32注册,它只显示正确的文件名的库A引用。



所以,我的问题是:有没有任何替代方法的库引用正确解决自己,而不必注册TLBs,只是把所有的文件在同一个目录中,或者附加一些清单?例如,将库的TLB重命名为.tlb或某种类别。

解决方案

尝试导入引用的A.tlb或者使用include()选项将它列在B.tlb的导入中。



只有#import 计划使用的接口的部分,如果您可以避免不必要地引入其他引用。 p>

I am maintaining a VS2010 project which has a number of cross-referenced COM libraries. I am trying to configure the project in such a way that it is buildable from a random workstation which has VS2010 installed. The workstation could be both 32 and 64 bit, so if I configure project to "register output", the build will fail to build on 32-bit machine, since 64-bit DLL will not be possible to load to call DllRegisterServer.

Here is an example: Typelib from project B references typelib from project A. Project C will reference project B via following statement:

#import "B.tlb"

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

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

I tried to open B.tlb using the OleView application, and it's sure as hell only showing right file name for library A reference if it is registered using regsvr32.

So, my question here is: is there any alternative way for library references to resolve themselves properly, without having to register TLBs, just by putting all the files in the same directory somehow, or attaching some sort of manifest? For example, rename the TLB for a library as .tlb or something of that sort.

解决方案

Try import the referenced A.tlb first, or list it in the import of B.tlb using the include() option.

Only #import the parts of the interface you plan to use if you can avoid bringing in other references unnecessarily.

这篇关于任何方式来解决C4772错误,而无需注册DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆