偶然发现一个奇怪的问题,VS2015 Enterprise版,添加类时,如果类名为ABC,VS弹出如下对话框,提示:“CodeModel操作失败。可能无法访问标记数据库”。但如果换一个类名则正常。这是VS2015的BUG?哪位安装相同VS版本的试试,是否也是这样?

解决方案 »

  1.   

    已测试,无任何问题。控制台下添加的,MFC没试。
      

  2.   

    怪了,我也是这种情况!但是设为ABCD就没有问题.
      

  3.   

    #import can optionally include one or more attributes. These attributes tell the compiler to modify the contents of the type-library headers. A backslash (\) symbol can be used to include additional lines in a single #import statement. For example:#import “test.lib” no_namespace \
       rename(“OldName”, “NewName”)……The rename attribute
    rename("OldName","NewName")OldNameOld name in the type libraryNewNameName to be used instead of the old nameThe rename attribute is used to work around name collision problems. If this attribute is specified, the compiler replaces all occurrences of OldName in a type library with the user-supplied NewName in the resulting header files.This attribute can be used when a name in the type library coincides with a macro definition in the system header files. If this situation is not resolved, then various syntax errors will be generated, such as C2059 and C2061.Note   The replacement is for a name used in the type library, not for a name used in the resulting header file.Here is an example: Suppose a property named MyParent exists in a type library, and a macro GetMyParent is defined in a header file and used before #import. Since GetMyParent is the default name of a wrapper function for the error-handling get property, a name collision will occur. To work around the problem, use the following attribute in the #import statement:rename(“MyParent”,”MyParentX”)which renames the name MyParent in the type library. An attempt to rename the GetMyParent wrapper name will fail:rename(“GetMyParent”,”GetMyParentX”)This is because the name GetMyParent only occurs in the resulting type library header file.
      

  4.   

    可能是因为与ABC Structure重名导致的吗?但是ABC Structure不是VS2015带来的新事物啊,老早就有了,为什么只在VS2015 Enterprise版中才出现这个问题呢?哪位装有Enterprise之外的VS 2015也帮试试看?
      

  5.   

    VS2010 下MFC项目中成功添加 C++ 类 ABC
      

  6.   

    2015以前版本都没有遇到过这个问题,我的是VS2015 Enterprise版。