Error running app but not while debugging!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don Gollahon

    #1

    Error running app but not while debugging!

    Help please! .NET 2.0.

    I have a hashtable defined:

    public static Hashtable Params;

    It currently is in a shared class in my app. I have moved it from the
    main form to the shared class but get the same results no matter what.

    When I run the app within VS it works fine! But when I run it outside
    of VS I get "object reference is not set to an instance of an object"
    and it is the Params.

    Any ideas how this could be?


    --

    Don Gollahon
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: Error running app but not while debugging!

    Hi,

    could you post some code?
    Also take a look in the deail of the exception , as the line # of where the
    error occurred.

    --
    Ignacio Machin
    The #1 Warehouse Management System & Direct Store Delivery Software (DSD) for QuickBooks & ERP Systems – LaceUp Solutions

    Mobile & warehouse Solutions.
    "Don Gollahon" <don.gollahon@n ospam.acs-inc.comwrote in message
    news:xn0fkwn20a j5pr000@news.mi crosoft.com...
    Help please! .NET 2.0.
    >
    I have a hashtable defined:
    >
    public static Hashtable Params;
    >
    It currently is in a shared class in my app. I have moved it from the
    main form to the shared class but get the same results no matter what.
    >
    When I run the app within VS it works fine! But when I run it outside
    of VS I get "object reference is not set to an instance of an object"
    and it is the Params.
    >
    Any ideas how this could be?
    >
    >
    --
    >
    Don Gollahon

    Comment

    • =?iso-8859-1?Q?Jos=E9_Joye?=

      #3
      Re: Error running app but not while debugging!

      Could you give more explanation about it.

      For instance, how do you intialize the Params member.
      At what line of code do you get the error (you can get it by looking at the
      stack trace of the error object.

      - José

      "Don Gollahon" <don.gollahon@n ospam.acs-inc.coma écrit dans le message de
      news:xn0fkwn20a j5pr000@news.mi crosoft.com...
      Help please! .NET 2.0.
      >
      I have a hashtable defined:
      >
      public static Hashtable Params;
      >
      It currently is in a shared class in my app. I have moved it from the
      main form to the shared class but get the same results no matter what.
      >
      When I run the app within VS it works fine! But when I run it outside
      of VS I get "object reference is not set to an instance of an object"
      and it is the Params.
      >
      Any ideas how this could be?
      >
      >
      --
      >
      Don Gollahon

      Comment

      • Don Gollahon

        #4
        Re: Error running app but not while debugging!

        Ignacio Machin ( .NET/ C# MVP ) wrote:
        Hi,
        >
        could you post some code?
        Also take a look in the deail of the exception , as the line # of
        where the error occurred.
        I inserted a test line to make sure this is where the problem was and
        it is. The following is in the Main() method:

        Main.GetINISett ings();
        try
        {
        string vstr = SharedClass.Par ams["LOGSERVER"].ToString();
        }
        catch (Exception E1)
        {
        MessageBox.Show ("Main Params: " + E1.Message);
        throw (new Exception(E1.Me ssage));
        }


        And here is the GetINISettings method:

        private void GetINISettings( )
        {
        if (System.IO.File .Exists(IniName ))
        {
        FileStream vini = new FileStream(IniN ame, FileMode.Open);
        StreamReader vsr = new StreamReader(vi ni);
        String[] elements;
        try
        {
        while (!vsr.EndOfStre am)
        {
        string vstr = vsr.ReadLine();
        elements = vstr.Split('=') ;
        SharedClass.Par ams.Add(element s[0], elements[1]);
        }
        }
        catch (Exception Ex)
        {
        vsr.Close();
        vini.Close();
        Environment.Exi tCode = 9000;
        throw (new Exception("Conf ig file not found or invalid: " +
        Ex.Message));
        //MessageBox.Show ("Config file not found or invalid. " +
        Ex.Message, "Error", MessageBoxButto ns.OK);
        return;
        };
        if (vsr != null)
        vsr.Close();
        if (vini != null)
        vini.Close();
        }
        }



        --

        Don Gollahon

        Comment

        • Don Gollahon

          #5
          Re: Error running app but not while debugging!

          Ignacio Machin ( .NET/ C# MVP ) wrote:
          Hi,
          >
          could you post some code?
          Also take a look in the deail of the exception , as the line # of
          where the error occurred.
          I forgot to include this in the sample I sent. It is before the other
          code in Main():

          SharedClass.Par ams = new Hashtable();

          --

          Don Gollahon

          Comment

          • Don Gollahon

            #6
            Re: Error running app but not while debugging!

            Ignacio Machin ( .NET/ C# MVP ) wrote:
            Hi,
            >
            could you post some code?
            Also take a look in the deail of the exception , as the line # of
            where the error occurred.
            Uhhh, nevermind.

            I forgot to move the ini file to the working directory.

            Good grief!

            --

            Don Gollahon

            Comment

            • Ignacio Machin \( .NET/ C# MVP \)

              #7
              Re: Error running app but not while debugging!

              Hi,

              Take a look at the ini file, must probably you are using a different version
              when you are debugging

              --
              Ignacio Machin
              The #1 Warehouse Management System & Direct Store Delivery Software (DSD) for QuickBooks & ERP Systems – LaceUp Solutions

              Mobile & warehouse Solutions.
              "Don Gollahon" <don.gollahon@n ospam.acs-inc.comwrote in message
              news:xn0fkwne6b 0s23001@news.mi crosoft.com...
              Ignacio Machin ( .NET/ C# MVP ) wrote:
              >
              >Hi,
              >>
              >could you post some code?
              >Also take a look in the deail of the exception , as the line # of
              >where the error occurred.
              >
              I inserted a test line to make sure this is where the problem was and
              it is. The following is in the Main() method:
              >
              Main.GetINISett ings();
              try
              {
              string vstr = SharedClass.Par ams["LOGSERVER"].ToString();
              }
              catch (Exception E1)
              {
              MessageBox.Show ("Main Params: " + E1.Message);
              throw (new Exception(E1.Me ssage));
              }
              >
              >
              And here is the GetINISettings method:
              >
              private void GetINISettings( )
              {
              if (System.IO.File .Exists(IniName ))
              {
              FileStream vini = new FileStream(IniN ame, FileMode.Open);
              StreamReader vsr = new StreamReader(vi ni);
              String[] elements;
              try
              {
              while (!vsr.EndOfStre am)
              {
              string vstr = vsr.ReadLine();
              elements = vstr.Split('=') ;
              SharedClass.Par ams.Add(element s[0], elements[1]);
              }
              }
              catch (Exception Ex)
              {
              vsr.Close();
              vini.Close();
              Environment.Exi tCode = 9000;
              throw (new Exception("Conf ig file not found or invalid: " +
              Ex.Message));
              //MessageBox.Show ("Config file not found or invalid. " +
              Ex.Message, "Error", MessageBoxButto ns.OK);
              return;
              };
              if (vsr != null)
              vsr.Close();
              if (vini != null)
              vini.Close();
              }
              }
              >
              >
              >
              --
              >
              Don Gollahon

              Comment

              • Don Gollahon

                #8
                Re: Error running app but not while debugging!

                Ignacio Machin ( .NET/ C# MVP ) wrote:
                Hi,
                >
                Take a look at the ini file, must probably you are using a different
                version when you are debugging
                Yep. Actually, blush, I forgot to copy it to the working directory and
                not just the development area.

                --

                Don Gollahon

                Comment

                Working...