First-chance exception in project.exe (COMCTL32.DLL): 0xC0000005: Access Violation.我看了很多属性页的源代码,觉得我的用法没什么问题阿,就是三个page,自己从cpropertysheet派生勒一个子类,在他的构造函数里添加三个页面,现在我已经给这个属性页加上应用逻辑的代码勒,工作也正常,就是程序运行后第一次domodal的时候有这个异常,以后在domodal就没有勒,我的os是win2000,vc6,希望大家能帮我解决.

解决方案 »

  1.   

    看看每个控件所连接的变量,是否有不存在的控件,而连接了变量就是在ctrl+w, Member Variables中察看
      

  2.   

    我看勒,没有关联不存在的控件和变量,我把form里头都删空,不关联任何控件也是一样啊
      

  3.   

    检查一下每个页的Border风格:Border不能是 Dialog Frame
      

  4.   

    SYMPTOMS
    Calling CPropertySheet::DoModal() or CPropertySheet::Create() in Windows 95 may cause an exception. The Output window displays a message that says the following: First-chance exception in <program.exe> (Comctl32.dll): 0xC0000005:
    Access Violation. 
    Newer versions (version 4.70) of the Comctl32.dll do not have this problem. CAUSE
    The CommCtl32.dll tries to modify the resources for the pages. Since the resources are normally in read-only sections this throws an Exception that can be caught in the application. However, if the application does not catch this exception then the OS will handle this exception correctly. RESOLUTION
    The first-chance exception can be ignored because it is safely handled by the operating system. One way to prevent the exception from being thrown is to make the resources read/write. You can do this by adding a linker setting of "/SECTION:.rsrc,rw." A second way to prevent the exception being thrown is to change the font of the pages so they are not "MS Sans Serif". MFC checks the dialog template font for the page. If it is not "MS Sans Serif" then it makes a copy of the resource in read/write memory, modifies the font and passes this to the C mCtl32.dll. So when the dll writes to the template for the page it is writing to read/write memory and hence exception is not thrown. Another way to prevent the exception from affecting your application is not to have the call for creating the property sheet in a try/catch(...) block. Instead catch particular exceptions in the catch block. If the property sheet is part of an OLE Automation Server that can be invoked through a method of the server then you have to make the resources read/write, using either of the first two methods described above, since OLE catches the exception. NOTE: Making the resources Read/Write can cause the resources to be written to a page file. STATUS
    This behavior is by design. MORE INFORMATIONSample Code   /* Compile options needed: default
       */    /***** this code will cause unpredictable results *****/ 
       try
       {
           sheet.DoModal();
       }
       catch(...)
       {
       }   /***** this code is OK *****/ 
       try
       {
           if (0 == sheet.DoModal())
               throw "DoModal() failed!";
       }
       catch(char * str)
       {
           TRACE ("Exception thrown: %s\n", str);
       } 
      

  5.   

    谢谢jiangsheng
    这也被你找到勒,admire阿