命名空间与.NET C ++冲突

时间:2014-01-17 18:31:51

标签: c++ sql-server-2005 c++-cli ado

我有一个我已经工作了一段时间的项目,并且我会定期看到来自windows include的模糊符号错误。它们通常与.net命名空间相关。该项目包括托管和非托管c ++代码,我最近决定在非托管类中使用文本文件进行日志记录切换到使用SQL Server通过ADO。在课程的标题中我使用

#import <C:\\Program Files\\Common Files\\System\\ado\\msado15.dll> rename( "EOF", "AdoNSEOF" )

根据MS的建议 - http://msdn.microsoft.com/en-us/library/windows/desktop/ms675103(v=vs.85).aspx

引入ADO。这在隔离中很好地编译,但是当从托管部分包含时,我得到如下错误:

3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(216) : error C2872: 'IDataObject' : ambiguous symbol
3>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(5948) : IDataObject'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IDataObject'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(216) : error C2872: 'IDataObject' : ambiguous symbol
3>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(5948) : IDataObject'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IDataObject'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(246) : error C2872: 'IDropTarget' : ambiguous symbol
3>        could be 'c:\program files\microsoft sdks\windows\v6.0a\include\oleidl.h(3328) : IDropTarget'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IDropTarget'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(246) : error C2872: 'IDropTarget' : ambiguous symbol
3>        could be 'c:\program files\microsoft sdks\windows\v6.0a\include\oleidl.h(3328) : IDropTarget'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IDropTarget'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(771) : error C2872: 'IMessageFilter' : ambiguous symbol
3>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(6328) : IMessageFilter'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IMessageFilter'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(771) : error C2872: 'IMessageFilter' : ambiguous symbol
3>        could be 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\objidl.h(6328) : IMessageFilter'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll : System::Windows::Forms::IMessageFilter'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(1041) : error C2872: 'IServiceProvider' : ambiguous symbol
3>        could be 'c:\program files\microsoft sdks\windows\v6.0a\include\servprov.h(103) : IServiceProvider'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::IServiceProvider'
3>c:\program files (x86)\microsoft visual studio 9.0\vc\include\comdefsp.h(1041) : error C2872: 'IServiceProvider' : ambiguous symbol
3>        could be 'c:\program files\microsoft sdks\windows\v6.0a\include\servprov.h(103) : IServiceProvider'
3>        or       'c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : System::IServiceProvider'

是否有某种方法可以封装冲突的命名空间,以免影响.NET?问题不断出现,似乎有些东西我不完全理解。 非常感谢, 布鲁斯。

1 个答案:

答案 0 :(得分:0)

您需要删除一些使用的命名空间声明并使用全名来避免冲突。