#import ADOX conflict with managed dll using ADO
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 msa开发者_运维知识库dox.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!
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!
精彩评论