添加对托管c ++项目的dll引用时编译器错误

时间:2021-09-04 19:50:25

I am using VS 2008 and get compiler errors sporadically when adding a dll reference to a managed c++ file in my C++ project. I am trying to add a reference to the dll so as to be able to use smart pointers. ex: #import items.tlb

我正在使用VS 2008并在我的C ++项目中向托管c ++文件添加dll引用时偶尔会出现编译器错误。我试图添加对DLL的引用,以便能够使用智能指针。例如:#import items.tlb

The problem is that the compiler crashes at sporadic places inside of items.tlh almost as though chunks of bytes where erased of missings , but when i open the file i can't find any reference to the aforementioned errors.

问题是编译器在items.tlh内部的零星位置崩溃,几乎就像删除了错误的字节块一样,但是当我打开文件时,我找不到任何对上述错误的引用。

I tried to rebuild the whole project several times, tried on different machine, but although the compiler errors are not consistents and disappear alltogether sometimes , a fresh rebuild sometimes brings back the problem. I was told that the size of the generated .tlh file may be a reason but it doesn't really solve my problem or point me in the right direction.

我尝试重建整个项目几次,尝试在不同的机器上,但是虽然编译器错误不是一致的,有时会完全消失,但重新进行的重建有时会带来问题。我被告知生成的.tlh文件的大小可能是一个原因,但它并没有真正解决我的问题或指向我正确的方向。

Did anybody experienced the same symptoms? Thank you

有没有人经历过相同的症状?谢谢

1 个解决方案

#1


Whenever I've had this problem, it was caused by linking a Debug build to a Release DLL or a Release build to a Debug DLL.

每当我遇到这个问题时,都是由于将Debug构建链接到Release DLL或Release构建到Debug DLL而引起的。

#1


Whenever I've had this problem, it was caused by linking a Debug build to a Release DLL or a Release build to a Debug DLL.

每当我遇到这个问题时,都是由于将Debug构建链接到Release DLL或Release构建到Debug DLL而引起的。