Intellisense中的C ++ / CLI错误,编译很好

时间:2012-03-16 05:59:46

标签: visual-studio-2012

......任何人都知道如何解决这些问题?

Visual Studio 2011 Beta,试图为此准备一些框架,现在通过一系列有限的问题。

代码是:

String^ pUser = (System::String^) pConnectionStringBuilder["UserName"];
String^ pPass = (System::String^) pConnectionStringBuilder["Password"];
String^ pBroker = (System::String^) pConnectionStringBuilder["Broker"];

pConnectionStringBuilder是ConnectionStringBuilder的一个实例。

错误:

2   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  39  Tradex.Connectivity.Rithmic
3   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  64  Tradex.Connectivity.Rithmic
4   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  63  39  Tradex.Connectivity.Rithmic
5   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  63  64  Tradex.Connectivity.Rithmic
6   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  64  41  Tradex.Connectivity.Rithmic
7   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  64  66  Tradex.Connectivity.Rithmic
8   IntelliSense: expression must have pointer-to-object or handle-to-CLI-array type    c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  269 6   Tradex.Connectivity.Rithmic
9   IntelliSense: expression must have integral or unscoped enum type   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  269 32  Tradex.Connectivity.Rithmic

他们根本没有任何意义;)

还有另外两个警告,但很明显这不是错误:

1> Tradex.Connectivity.Rithmic.vcxproj - > C:\工作\特瑞\来源\调试\ Tradex.Connectivity.Rithmic.dll rithmicconnector.cpp(104):警告:C6001:使用未初始化的内存'oParams'。 rithmicconnector.cpp(108):警告:C6001:使用未初始化的内存'oLoginParams'。 1 GT;代码分析完成 - 0个错误,0个警告

它汇编得很好。

我尝试使用pConnectionStringBuilder->默认 - 猜猜是什么;)抱怨。

2   IntelliSense: class "System::Data::Common::DbConnectionStringBuilder" has no member "default"   c:\Work\Tradex\Source\Tradex.Connectivity.Rithmic\RithmicConnector.cpp  62  65  Tradex.Connectivity.Rithmic

顺便提一下也是错误的并且编译;)

我真的不想有智能感知错误。

3 个答案:

答案 0 :(得分:11)

C ++ / CLI的Intellisense经常会混淆并报告误报错误。它根本不如C#的Intellisense好。公平地说,C ++代码通常比C#代码更难分析(例如,如果我将一个#define编译指示添加到头文件中,导入头文件的任何文件的结构可能会完全改变 < / em>的)。

一旦我开始看到虚假的智能感知错误,我通常只是在错误列表窗口中关闭它们:

  1. 右键单击“错误列表”窗口的内容
  2. 取消选中“显示智能感知错误”

答案 1 :(得分:1)

如果您一直在使用C ++并且受到Intellisense错误的困扰,您可能需要永久关闭此错误报告: 工具 - &gt;选项 - &gt;文字编辑器 - &gt; C / C ++ - &gt;高级 - &gt; IntelliSence - &gt;禁用错误报告

答案 2 :(得分:1)

我发现如果一个文件没有换行结束(例如,包含文件的最后一行是#endif并且之后没有CRLF)它会搞乱Intellisense并导致它被标记错误。