I am new at programming and would like someone to assist me as to what I am looking for?

As far as I know I have followed the instructions I found on one of the sites. Can someone please help?
I am using VStudio 2008, creating an MFC application.

I am trying to create a new property sheet based application.
All I have is 1 property page and the property sheet itself.
I have just created this project. Basically it's an empty project.
When I run it through the debugger I get the following error:

First-chance exception at 0x5d0c373e in Temp.exe: 0xC0000005: Access violation writing location 0x00435454.

The debugger stops at:

BOOL AFXAPI AfxDeactivateActCtx(DWORD dwFlags, ULONG_PTR ulCookie)
    BOOL rc = pfnDeactivateActCtx != 0 ? pfnDeactivateActCtx(dwFlags, ulCookie) : FALSE;
    return rc;

Will someone be nice and help?
Thanks a million.

Edited by Reverend Jim: Fixed formatting

7 Years
Discussion Span
Last Post by fish786

Well, not having '08, I'm stabbing in the dark here, but the primary suspect is pfnDeactivateActCtx. One of the easiest ways to get the "0xC0000005" violation is to access garbage memory. I recommend stepping through where pfnDeactivateActCtx is initialized. I'd bet that it's not happening correctly or not happening at all, and pfnDeactivateActCtx is a garbage address.

If you're still having trouble, I recommend you post the pfnDeactivateActCtx init code, that will tell us more.


Thanks for trying to help me. I have put Traces and I am getting the error after this statement.

BOOL bResult = CPropertySheet::OnInitDialog();

This is the First and only statement I have in the OnInitDialog of my Property Sheet class.


> The debugger stops at:
Work your way back up the call stack, and work your way back through each nested function code.
Examine the variables in each nested function, are they all set correctly for the current moment?

Put a breakpoint at the start of the calling function, re-run the code, then single-step and examine data as you go.


I just tried this. I have a feeling it's something in the project setting or compiler options. I am not sure what the compiler options should be even though I left them at default.

Here is what I have done to create this project as per the instructions on one of the sites.

1) Create a dialog based application.
2) Create Property pages.
3) Using the add class create a derived class from property sheet.
4) Change the following in theAPP

CLastTrySheet dlg(_T("LastTry"));
dlg.m_psh.dwFlags |= PSH_NOAPPLYNOW;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();

Step 6: The constructor of the sheet.

CLastTrySheet::CLastTrySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
CLastTrySheet::CLastTrySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(pszCaption, pParentWnd, iSelectPage)

Step 7: In the OnInitDialog:

BOOL CLastTrySheet::OnInitDialog()
    TRACE("Exception error b4.\n"); 
               BOOL bResult =  CPropertySheet::OnInitDialog();
    TRACE("Exception error After.\n"); 

The above is the only code I have in the OnInitDialog.

I get my error in CPropertySheet::OnInitDialog();

Is there a way in debug to check "Access violation writing location 0x00416e8c". Whats at this location?
If thats what you asked me to do, I am sorry I don't know where to look for it in debug.

Thanks for your help.

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.