我用ADO写了一个上传,下载图像到数据库的代码,应用程序已经测试通过我试着把它编译成DLL时,出现了这样的问题:File -> New ->Project(MFC AppWizard(DLL)我在stdafx.h中加入这两行:
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "ADOEOF")
#include "ole2.h"其它代码还没写,编译出现如下问题:c:\...\msado15.tlh(143) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
c:\...\msado15.tlh(184) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
c:\...\msado15.tlh(228) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
c:\...\msado15.tlh(245) : error C2011: 'EditModeEnum' : 'enum' type redefinition
c:\...\msado15.tlh(253) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
c:\...\msado15.tlh(432) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
Error executing cl.exe.2.dll - 6 error(s), 0 warning(s)
这是为什么?
谢谢!

解决方案 »

  1.   

    #include "ole2.h"
     不要放在stdafx.h中
      

  2.   

    应该是头文件的包含有问题,你按照MFC自动产生的格式检查一下你的代码!
      

  3.   

    To: romanticist(让我拥抱你入梦)现在我把 #include "old2.h" 从stdafx.h中去了,或者放到
    别的文件中,还是再现同样的问题。高手发言啊!谢过各位了!
      

  4.   

    “identifier”:“type”类型重定义该标识符已定义为 type 类型。如果多次将某个类型库导入同一个文件,也可能生成 C2011。例如:struct S;
    union S;    // Error C2011
    解决办法:在stdafx.h中开始处加入
    #pragma onceSpecifies that the file will be included (opened) only once by the compiler in a build. This can reduce build times as the compiler will not open and read the file after the first #include of the module.For example,// header.h
    #pragma once
      

  5.   

    d:\...\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>在stdafx.h中加了#pragma once之后,原来的错误不存在,但是出了上面
    这样的错误。怎么搞定它?
      

  6.   

    命令空间重复了
    改成这样
    #import "C:\Program Files\common files\system\ado\msado15.dll"  rename_namespace("AdoNS") rename("EOF","adoEOF")using namespace AdoNS;
      

  7.   

    这个问题我遇到过.问题就在stdafx.h中.
    你试着改换嵌入文件的位置,删除一些不必的include文件.就是这样.或着找个例程,对校一下这个头文件.