locked
Strange appearance of the "Object Reference not set" error message RRS feed

  • Question

  • About two months ago, I updated from VB2010 Express and Win7(x64) from VB2008 Standard and Win7(x86) and have been tweaking a programme and some user controls I have been using for some years.  In the last three days only whenever I open the programme and run it, I get the error message box "Object Reference not set to an insatnce of an object"" three or four times.  The programme then runs correctly.  If I stop and restart the programme, the error message not reappear.  If I then edit code and rerun (or save) the programme, the error message reappears.  The error messages do not appear if I run the programme from the EXE file pinned to my taskbar

    I have been unable to trap the error message to find out on the stack a clue to the line in the programme that is causing the problem.  I do not add controls at runtime and all have been added to the designer at design time.

    Because the problem has suddenly appeared from nowhere I am not sure how to cure it.

    Any ideas?

    regards

    Colin Reid

    Sunday, November 21, 2010 4:59 PM

Answers

  • Slightly confused by your first sentence. Are you running under 64-bit Windows?  Are you using the Express Edition or VS 2008? If you are running under 64-bit Windows then you probably need to change the Platform option to x86 and rebuild.

    The exception is related to COM, so somewhere in your code you are using a COM or ActiveX component.

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Kee Poppy Monday, November 29, 2010 5:38 AM
    Monday, November 22, 2010 3:47 PM
  • Microsoft's notification system seems to get backed up at times or stop altogether. You should probably be seeing responses now since it seems to be fixed.

    As far as the issue is concerned, most ActiveX or COM components simply will not run in a project that is set for "Any CPU" under 64-bit Windows (app runs as a 64-bit proces), because they are limited to running in a 32-bit environment. You either have to remove or replace them in order to run 64-bit, or set the Platform option to x86 so that the app is forced to run in 64-bit WoW (the 32-bit sub system).


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Kee Poppy Monday, November 29, 2010 5:38 AM
    Friday, November 26, 2010 4:06 PM

All replies

  • Is the Visual Studio project behavior the same with and without the Debugger?

    I assume that this problem has always appeared with the VS2010 version of the application.  Did you notice any messages from the upgrade wizard?


    Mark the best replies as answers. "Fooling computers since 1971."

    http://rudedog2.spaces.live.com/default.aspx

    Sunday, November 21, 2010 5:21 PM
  • Do you have any dependencies on an external server, such as a database server or web service?  Might they be unreachable at times recently where they were reliable previously?

    --
    Mike
    Sunday, November 21, 2010 10:13 PM
  • Slightly confused by your first sentence. Are you running under 64-bit Windows?  Are you using the Express Edition or VS 2008? If you are running under 64-bit Windows then you probably need to change the Platform option to x86 and rebuild.

    The exception is related to COM, so somewhere in your code you are using a COM or ActiveX component.

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Kee Poppy Monday, November 29, 2010 5:38 AM
    Monday, November 22, 2010 3:47 PM
  • Win7(x64) and VB2010 Express.  At the moment the compiler is set to Any CPU.  I have tried to set it X86 in the past but some of my nonMS controls stopped working.  As it is not broke...

    Actually, I found the answer by accident as I had delected some MS print controls in the Form Designer but they did not deleted from the Form,Designer,VB file.  Once I had done that manuall y the error reports stopped.

    Please someone note - I posted on 21st November and replies were posted on 22nd but I have been unable to see them until the 25th (I check every day.  WHY?

    regards

    Colin Reid

     

    Friday, November 26, 2010 3:51 PM
  • see my answer to Paul Clement

    Thanks for your help

    Friday, November 26, 2010 3:52 PM
  • see my answer to Paul Clement

    Thanks for your help

    Friday, November 26, 2010 3:52 PM
  • Microsoft's notification system seems to get backed up at times or stop altogether. You should probably be seeing responses now since it seems to be fixed.

    As far as the issue is concerned, most ActiveX or COM components simply will not run in a project that is set for "Any CPU" under 64-bit Windows (app runs as a 64-bit proces), because they are limited to running in a 32-bit environment. You either have to remove or replace them in order to run 64-bit, or set the Platform option to x86 so that the app is forced to run in 64-bit WoW (the 32-bit sub system).


    Paul ~~~~ Microsoft MVP (Visual Basic)
    • Marked as answer by Kee Poppy Monday, November 29, 2010 5:38 AM
    Friday, November 26, 2010 4:06 PM