#import ADOX与托管dll中的ADOX冲突 [英] #import ADOX conflict with ADOX in a managed dll

查看:96
本文介绍了#import ADOX与托管dll中的ADOX冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的C ++应用程序,它使用/clr调用托管的dll(用C#编写)

该应用程序使用#import引用ADOX.该dll还引用了ADOX.

一切正常,直到我将对dll的引用添加到C ++项目.然后,在编译与msadox.tlimsadox.tlh相关的STDAFX.CPP时出现数百个错误.一些错误涉及接口重新定义等,而其他错误则试图像编译托管代码一样尝试编译tlh和tli.
我曾尝试在#import周围尝试#pragma managed(off),但未成功.

如果相关,则#import使用libid:...方法.

我不明白这种冲突是如何发生的,以及我能做些什么来克服它.请帮忙!

I have a legacy C++ application using /clr calling a managed dll (written in C#)

The app uses #import to reference ADOX. The dll also references ADOX.

Everything is fine until I add a reference to my dll to the C++ project. Then I get hundreds of errors when compiling STDAFX.CPP related to msadox.tli and msadox.tlh. Some of the errors refer to interface redefinition and suchlike, others to trying to compile the tlh and tli as if they were managed code.

I''ve tried #pragma managed(off) around the #import without success.

In case it''s relevant the #import uses the libid:... method.

I don''t understand how this conflict occurs and what I can do to overcome it. Please help!

推荐答案

我通过从C ++项目引用中删除dll引用并在单个cpp文件中使用#using "my_managed.dll"解决了这个问题.指的是dll).

然后,编译器警告我它无法从dll中导入一些ADOX符号,因为它们已经被定义(由#import ...定义),但是由于它们只是警告,因此我可以使用#pragma将其关闭并忽略它们.

现在一切正常! :thumbsup:
I got round the problem by removing the dll reference from the C++ project references and using #using "my_managed.dll" in a single cpp file (the only one that refers to the dll).

Then the compiler warned me that it was unable to import some ADOX symbols from the dll because they had already been defined (by the #import ...) but because they were only warnings I could use a #pragma to turn them off and ignore them.

Now everything works! :thumbsup:


这篇关于#import ADOX与托管dll中的ADOX冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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