none
Object reference not set to an instance of an object

    Question

  • Hi,

    I am getting the above error with the below details when I install the application as package on another PC but the same application is running fine on my local PC. The stored procedure has no problem because I am able to invoke the code on the server directly.. so where is the problem? kindly assist...

    here is the error:

    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
       at PriceList.frmMain.populate_family_physician()
       at PriceList.frmMain.frmMain_Load(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    PriceList
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/PriceList.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    DevExpress.XtraEditors.v11.1
        Assembly Version: 11.1.4.0
        Win32 Version: 11.1.4.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/DevExpress.XtraEditors.v11.1.DLL
    ----------------------------------------
    DevExpress.XtraGrid.v11.1
        Assembly Version: 11.1.4.0
        Win32 Version: 11.1.4.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/DevExpress.XtraGrid.v11.1.DLL
    ----------------------------------------
    DevExpress.Utils.v11.1
        Assembly Version: 11.1.4.0
        Win32 Version: 11.1.4.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/DevExpress.Utils.v11.1.DLL
    ----------------------------------------
    DevExpress.Data.v11.1
        Assembly Version: 11.1.4.0
        Win32 Version: 11.1.4.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/DevExpress.Data.v11.1.DLL
    ----------------------------------------
    DevExpress.Printing.v11.1.Core
        Assembly Version: 11.1.4.0
        Win32 Version: 11.1.4.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/DevExpress.Printing.v11.1.Core.DLL
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Data
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    MySql.Data
        Assembly Version: 6.3.5.0
        Win32 Version: 6.3.5.0
        CodeBase: file:///C:/Program%20Files/RMC/Price%20List/MySql.Data.DLL
    ----------------------------------------
    System.Transactions
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.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.
    
    


    Jassim Rahma

    Monday, May 14, 2012 4:27 PM

Answers

  • but the problem is with Ferrari Cor Ligthert.

    I found where is the problem guys..

    The App.Config file was not deployed with the project.

    I guess Microsoft error must be more clear in such case :)

    Thanks everyone..


    Jassim Rahma

    • Marked as answer by Jassim Rahma Wednesday, May 16, 2012 3:58 PM
    Wednesday, May 16, 2012 3:58 PM

All replies

  • Please show a code piece where probably there is a problem.
    Monday, May 14, 2012 4:48 PM
  • You can see, from the stack trace, that the problem is in the populate_family_physician() method.  You are referencing and using a variable that hasn't been setup properly.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 14, 2012 5:26 PM
  • Hi Jassim,

    It would be better if you can post a piece of related code here as YataJga suggested. This will be very helpful to us to find the root cause easily.

    You can also try Reed's suggestion.

    I look forward you.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 15, 2012 11:29 AM
  • but I can't see where is the problem specially it's working fine my laptop when I connect to local and remote database.

    here is the code:

    private void populate_family_physician()
    {
        this.Cursor = Cursors.WaitCursor;
    
        data_table = new DataTable();
    
        sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[&quot;SQLdb&quot;].ConnectionString);
    
        // try
        // {
        sql_connection.Open();
        sql_command = new MySqlCommand(&quot;sp_get_pricelist_by_code&quot;, sql_connection);
        sql_command.CommandType = CommandType.StoredProcedure;
        sql_command.Parameters.AddWithValue(&quot;param_pricelist_code&quot;, &quot;FamilyPhysician&quot;).MySqlDbType = MySqlDbType.VarChar;
        sql_adapter = new MySqlDataAdapter(sql_command);
        sql_adapter.Fill(data_table);
        dataFamilyPhysician.DataSource = null;
        dataFamilyPhysician.ResetBindings();
        dataFamilyPhysician.DataSource = data_table;
    
        gridFamilyPhysician.Columns[&quot;price_list_id&quot;].Caption = &quot;price_list_id&quot;;
        gridFamilyPhysician.Columns[&quot;price_list_id&quot;].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        gridFamilyPhysician.Columns[&quot;price_list_id&quot;].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        gridFamilyPhysician.Columns[&quot;price_list_id&quot;].Width = 80;
        gridFamilyPhysician.Columns[&quot;price_list_id&quot;].Visible = false;
    
        gridFamilyPhysician.Columns[&quot;price_list_description&quot;].Caption = &quot;Description&quot;;
        gridFamilyPhysician.Columns[&quot;price_list_description&quot;].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Default;
        gridFamilyPhysician.Columns[&quot;price_list_description&quot;].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Default;
        gridFamilyPhysician.Columns[&quot;price_list_description&quot;].Width = 150;
    
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].Caption = &quot;Price&quot;;
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].DisplayFormat.FormatString = &quot;#,###,##0.000&quot;;
        gridFamilyPhysician.Columns[&quot;price_list_price&quot;].Width = 50;
    
        this.Cursor = Cursors.Default;
    }



    Jassim Rahma

    Tuesday, May 15, 2012 2:41 PM
  • Hi Jassim,

    Would you like to tell us which line throw the exception?

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 16, 2012 5:42 AM
  • Maybe would be a good place to look for an answer on your question a MySQL forum. 

    If it is working on your laptop, and the server is MySQL you can seek endless times. 

    But don't ask in a Ferrari workplace how to fix problems with a Lada.


    Success
    Cor

    Wednesday, May 16, 2012 10:05 AM
  • but the problem is with Ferrari Cor Ligthert.

    I found where is the problem guys..

    The App.Config file was not deployed with the project.

    I guess Microsoft error must be more clear in such case :)

    Thanks everyone..


    Jassim Rahma

    • Marked as answer by Jassim Rahma Wednesday, May 16, 2012 3:58 PM
    Wednesday, May 16, 2012 3:58 PM
  • Hi,

    Please can You send full code

    Monday, July 30, 2012 11:02 AM