Exception thrown at 0x723F8B1E (comctl32.dll) in WindowsApp1.exe: 0xC0000005: Access violation writing location 0x00000002 RRS feed

  • Question

  • I have an access violation error in my WinForms app (WindowsApp1.exe) which says:

    Exception thrown at 0x723F8B1E (comctl32.dll) in WindowsApp1.exe: 0xC0000005: Access violation writing location 0x00000002

    which means it's trying to access location 0x00000002 (2) When an task dialog or a dialog, or anything, is done on the computer, the function which does so allocates an memory address, then writes to it the information needed to complete, which this action can raise an error if the address allocated is not within your allocated address space (i.e. an address allocated by the system) such as 0x00000002, That happens when I implement TaskDialogIndirect() as follows:

    Declare Function TaskDialogIndirect Lib "comctl32" (TASKDIALOGCONFIG, Integer, Boolean, Boolean) As Long
    TaskDialogIndirect(tdc, 2, Nothing, Nothing);

    (I wrote the types only because I don't remember the names of the parameters) It causes an error because comctl32.dll is trying to write to 0x00000002 (WinForms apps always load comctl32.dll v6) So the problem is in the , function, the function call, or the parameters to the function.

    How do I solve this?

    Wednesday, March 8, 2023 2:51 PM

All replies

  • The error message you're seeing indicates that an exception was thrown while trying to write to a location in memory that is not accessible. Specifically, the error is related to the comctl32.dll file, a Windows operating system component.

    There are several possible causes for this error, including:

    1. Corrupted system files: If the comctl32.dll file or other system files have become corrupted, this can lead to errors like the one you see.
    2. Outdated or incompatible software: Running outdated or incompatible software that relies on the comctl32.dll file can also cause errors.
    3. Malware or viruses: Malware or viruses on your computer can cause errors by modifying system files or interfering with the normal operation of your computer.

    To resolve this issue, you can try the following steps:

    1. Update your operating system: Ensure your Windows system is updated with the latest security patches and updates.
    2. Scan for malware and viruses: Use an antivirus or antimalware software to scan your computer for malware and viruses that could be causing the error.
    3. Reinstall the affected software: If the error is related to a specific software program, try uninstalling and then reinstalling the program to see if that resolves the issue.
    4. Repair system files: Use the System File Checker tool to check and repair any corrupted system files that may be causing the error.

    If none of these steps resolve the issue, you may need further assistance from a computer technician or Microsoft support.

    • Proposed as answer by Hajira Banu Monday, March 27, 2023 5:52 PM
    Monday, March 27, 2023 5:52 PM
  • It turns out, because the second param is 2, it writes to 0x2, causing an error,

    it should be:

    Declare Function TaskDialogIndirect Lib "comctl32" (TASKDIALOGCONFIG, ByRef Integer, Boolean, Boolean) As Long
    Dim BSelected As Integer = 0
    TaskDialogIndirect(tdc, BSelected, Nothing, Nothing);

    Friday, March 31, 2023 11:18 AM