dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: access violation reading location 0x00000000

  1. #1
    Join Date
    Jul 2018
    Posts
    7

    Post access violation reading location 0x00000000

    hello..
    i am running a thread.but when i try to print anything edit box using the line
    aa.Format("%d",i);
    ts->_this->GetDlgItem(IDC_EDIT3)->SetWindowText(aa);//run time error occurs here.

    my code is compilation error free.but i get an error when i run it as
    access violation reading location 0x00000000

    plz help.

  2. #2
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,362

    Re: access violation reading location 0x00000000

    You are trying to dereference a pointer that has a value of 0 (null). In the debugger put a breakpoint on that line and examine the contents of the variables. You'll then know which is the one that is 0.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.1)

  3. #3
    Join Date
    Jul 2018
    Posts
    7

    Re: access violation reading location 0x00000000

    thanks for the reply..but even though i put a breakpoint on that particular line in debug mode.i am not able check the values of the variables..most of my variables are global variables..plz help.

  4. #4
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,362

    Re: access violation reading location 0x00000000

    What compiler/debugger are you using?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.1)

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,195

    Re: access violation reading location 0x00000000

    Quote Originally Posted by Ramdhyani View Post
    hello..
    i am running a thread.but when i try to print anything edit box using the line
    aa.Format("%d",i);
    ts->_this->GetDlgItem(IDC_EDIT3)->SetWindowText(aa);//run time error occurs here.

    my code is compilation error free.but i get an error when i run it as
    access violation reading location 0x00000000

    plz help.
    1. What is ts?
    2. What is _this?
    3. Are you trying to access the IDC_EDIT3 control from within a worker thread? It appears to be a wrong design. Please, check out this great Joe Newcomer's essay: Using Worker Threads
    Victor Nijegorodov

  6. #6
    Join Date
    Jul 2018
    Posts
    7

    Re: access violation reading location 0x00000000

    vc++ 2010

  7. #7
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,362

    Re: access violation reading location 0x00000000

    vc++ 2010
    Then when the break point triggers you should be able to view the contents of the variables - and see which pointer is 0.

    See
    https://blogs.msdn.microsoft.com/dev...visual-studio/
    https://msdn.microsoft.com/en-us/lib...v=vs.100).aspx
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2017 (15.8.1)

  8. #8
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,112

    Re: access violation reading location 0x00000000

    The UI and all its controls should only be modified from the main thread, not from worker threads.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)