You receive a "0xC0000005: Access Violation" error message when you call the CPropertySheet::DoModal method or the Create method in Visual C++ (158552)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
This article was previously published under Q158552 SYMPTOMSWhen you call CPropertySheet::DoModal() or
CPropertySheet::Create(), an exception might occur. The Output window displays the following message: First-chance
exception in <program.exe> (Comctl32.dll): 0xC0000005: Access Violation.
The exception is expected and is handled by the operating system.
This will only occur the first time you call either of these methods and
subsequent calls will not generate this first-chance exception. CAUSE The CommCtl32.dll tries to modify the resources for the
pages. Because the resources are typically in read-only sections, this throws a
first-chance exception that will be caught by the operating system. The operating system handles this
exception and makes the resources writeable and then everything completes
normally. Because the resources are now writeable, all subsequent calls complete
without this first-chance exception RESOLUTION The first-chance exception can be ignored because it is
safely handled by the operating system. To prevent the exception, use one of the following methods: - Method 1: Make the resources read/write. You can do
this by adding a linker setting as follows:
/SECTION:.rsrc,rw - Method 2: 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, MFC makes a copy of the resource in read/write
memory, and then modifies the font and passes this to the C mCtl32.dll. When the DLL
writes to the template for the page, it is writing to read/write memory. Therfore, an exception is not thrown.
- Method 3: Do not 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, make the resources read/write by using one of the first two methods
because OLE catches the exception. Note When you change the resources to Read/Write, the resources might be
written to a page file. STATUS This
behavior is by design.REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
126630
Resource sections are read-only
Modification Type: | Major | Last Reviewed: | 6/2/2005 |
---|
Keywords: | kbtshoot kbcode kbprb KbUIDesign KB158552 kbAudDeveloper |
---|
|