none
System.NullReferenceException: Object reference not set to an instance of an object! Need Help!

    Question

  • Hi Everyone!

    Urgent Help!

     

    Why I receive this error during runtime?

     

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.TypeInitializationException: The type initializer for 'MYPSApp.mdlMain' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Mainform.resizeGUI(clsSplitLayout& splitter)
       at Mainform.main_Resize(Object eventSender, EventArgs eventArgs)
       at System.Windows.Forms.Control.OnResize(EventArgs e)
       at System.Windows.Forms.Form.OnResize(EventArgs e)
       at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
       at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
       at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height)
       at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
       at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
       at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
       at System.Windows.Forms.Control.set_Size(Size value)
       at System.Windows.Forms.Control.SetClientSizeCore(Int32 x, Int32 y)
       at System.Windows.Forms.Form.SetClientSizeCore(Int32 x, Int32 y)
       at System.Windows.Forms.Control.set_ClientSize(Size value)
       at System.Windows.Forms.Form.set_ClientSize(Size value)
       at Mainform.main.InitializeComponent()
       at Mainform.main..ctor()
       at Mainform.mdlMain.cctor()
       --- End of inner exception stack trace ---
       at Mainform.main.mdlMain.Main_Renamed(frmSplash& dlg)
       atMainform.main.frmSplash.tmrsplash_Tick(Object eventSender, EventArgs eventArgs)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.6400 (Win8RTMGDR.050727-6400)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    Mainform
        Assembly Version: 1.0.4934.15422
        Win32 Version: 1.0.4934.15422
        CodeBase: file:///C:/Users/palajs/Desktop/Mainform.main/client/Mainform.NET/Backup/bin/Mainform.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.6402 (Win8RTMGDR.050727-6400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.6401 (Win8RTMGDR.050727-6400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.6401 (Win8RTMGDR.050727-6400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.6387 (Win8RTM.050727-6300)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    Microsoft.VisualBasic.PowerPacks.Vs
        Assembly Version: 10.0.0.0
        Win32 Version: 11.0.50727.1
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic.PowerPacks.Vs/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.PowerPacks.Vs.dll
    ----------------------------------------
    Microsoft.VisualBasic.Compatibility
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.6387
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic.Compatibility/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.Compatibility.dll
    ----------------------------------------
    AxInterop.MSWinsockLib
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Users/palajs/Desktop/MYPS%20latest/client/MYPSApp.NET/Backup/bin/AxInterop.MSWinsockLib.DLL
    ----------------------------------------
    AxInterop.MSComctlLib
        Assembly Version: 2.1.0.0
        Win32 Version: 2.1.0.0
        CodeBase: file:///C:/Users/palajs/Desktop/MYPS%20latest/client/MYPSApp.NET/Backup/bin/AxInterop.MSComctlLib.DLL
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.6387 (Win8RTM.050727-6300)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

    How can I fix this.

    Anyone Could Help me? Please comment.. Thanks very much in advance..


    Jonel

    Friday, July 05, 2013 1:21 AM

Answers

  • resizeGUI is a method and does not have a value.  The culprit would appear to be the variable m_splitter, which is being passed as an argument to the method.  When the error occurs, what is the value of m_Splitter (note that you are interested in the value of the variable, not the declaration like you have provided for resizeGUI).

    If it turns out the m_Splitter is Nothing then that may be the result of the warning provided in the line above - "mainform.Resize may fire when form is initialized" which could be before m_Splitter is initialized.  You may be able to avoid the problem by changing the code to:

    Private Sub mainform_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
        If Not m_Splitter Is Nothing Then
                resizeGUI(m_splitter
        End If
    End Sub

    • Edited by Acamar Friday, July 05, 2013 6:12 AM code
    • Marked as answer by CodeGenre Monday, July 08, 2013 6:33 AM
    Friday, July 05, 2013 5:16 AM

All replies

  • btw, I use VS 2012


    Jonel

    Friday, July 05, 2013 1:29 AM
  • Why I receive this error during runtime?

    The need to examine the line of code at which the error occurs.

    The message is telling you that you are trying to use a variable before a valid object has been created for that variable.

    You need to create the error in the debugger.  When the error occurs, look at each variable in the error line. One of them will be Nothing.

    Friday, July 05, 2013 2:21 AM
  • You need to create the error in the debugger.  When the error occurs, look at each variable in the error line. One of them will be Nothing.

    Hi thanks for a quick response,

    What do you mean by this,

    I trace the first line error, I find all reference on the first line but I don't see a "reference that is equivalent to nothing"

    Please give me another explanation, I am a little bit of noob in this language. and I am confuse to this runtime error..thanks


    Jonel

    Friday, July 05, 2013 2:57 AM
  • I trace the first line error, I find all reference on the first line but I don't see a "reference that is equivalent to nothing"

    What is the code for the line that is giving you the error?

    What are the values of each of the variables in that line?

    Please note I did not say "reference that is equivalent to nothing". What you will find is a variable that is Nothing. Nothing is a defined value in .Net and the debugger will identify it explicitly.

    Friday, July 05, 2013 3:13 AM
  • This are the lines where the error occur..

    UPGRADE_WARNING: Event mainform.Resize may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'

    Private Sub mainform_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize

     

                resizeGUI(m_splitter

     

    End Sub

    'This is the reference for resizeGUI
    Private


     Sub resizeGUI(ByRef splitter As clsSplitLayout)

    splitter.Resize_Renamed(50, VB6.PixelsToTwipsY(toolBarMyps.Height) + 50, VB6.PixelsToTwipsX(


    Me.Width) - 200, VB6.PixelsToTwipsY(Me.ClientRectangle.Height) - VB6.PixelsToTwipsY(toolBarMyps.Height) - 100)


    End Sub

     can you help me to fix this.. thanks..


    Jonel

    Friday, July 05, 2013 5:11 AM
  • resizeGUI is a method and does not have a value.  The culprit would appear to be the variable m_splitter, which is being passed as an argument to the method.  When the error occurs, what is the value of m_Splitter (note that you are interested in the value of the variable, not the declaration like you have provided for resizeGUI).

    If it turns out the m_Splitter is Nothing then that may be the result of the warning provided in the line above - "mainform.Resize may fire when form is initialized" which could be before m_Splitter is initialized.  You may be able to avoid the problem by changing the code to:

    Private Sub mainform_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
        If Not m_Splitter Is Nothing Then
                resizeGUI(m_splitter
        End If
    End Sub

    • Edited by Acamar Friday, July 05, 2013 6:12 AM code
    • Marked as answer by CodeGenre Monday, July 08, 2013 6:33 AM
    Friday, July 05, 2013 5:16 AM
  • resizeGUI is a method and does not have a value.  The culprit would appear to be the variable m_splitter, which is being passed as an argument to the method.  When the error occurs, what is the value of m_Splitter (note that you are interested in the value of the variable, not the declaration like you have provided for resizeGUI).

    If it turns out the m_Splitter is Nothing then that may be the result of the warning provided in the line above - "mainform.Resize may fire when form is initialized" which could be before m_Splitter is initialized.  You may be able to avoid the problem by changing the code to:

    Private Sub mainform_Resize(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Resize
        If Not m_Splitter Is Nothing Then
                resizeGUI(m_splitter
        End If
    End Sub

    ..thanks for this. but when i run the system the m_splitter that devides the form so that some object are in proper place are gone. and also i another problem encounter that log in procedure are continuously appearing and every time i put some character on the txtbox provided the inputs are vanish..

    this is strange.. don't have errors in the list when i build the program.. it's only during runtime.. can i ask for more help.. Thanks..


    Jonel

    Friday, July 05, 2013 7:25 AM
  • ..thanks for this. but when i run the system the m_splitter that devides the form so that some object are in proper place are gone. and also i another problem encounter that log in procedure are continuously appearing and every time i put some character on the txtbox provided the inputs are vanish.

    What was the value of m_Splitter when the error occurred?

    You need to attack the errors one by one using the procedure that I described - when the code stops at that point examine the values of the variables involved and work out why they aren't what you expect them to be.

    Friday, July 05, 2013 12:22 PM
  • ..thanks for this. but when i run the system the m_splitter that devides the form so that some object are in proper place are gone. and also i another problem encounter that log in procedure are continuously appearing and every time i put some character on the txtbox provided the inputs are vanish.

    What was the value of m_Splitter when the error occurred?

    You need to attack the errors one by one using the procedure that I described - when the code stops at that point examine the values of the variables involved and work out why they aren't what you expect them to be.

    Hi,

    There's no error Occur. is just that when I run the system m_splitter is nothing(meaning the division on my mainform was lost) and some object are in the wrong position. :(..

    but I figure it out what was the problem and I finally fix.. :).. thanks a lot..and I considered this as solved..

    btw, I've encounter another problem and I post another thread.. hope you can help again.. Thanks..


    Jonel

    Monday, July 08, 2013 6:33 AM