Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Error running app but not while debugging!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don Gollahon - 07 Jan 2008 18:37 GMT
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?

Signature

Don Gollahon

José Joye - 07 Jan 2008 18:45 GMT
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é

> Help please!  .NET 2.0.
>
[quoted text clipped - 10 lines]
>
> Any ideas how this could be?
Ignacio Machin ( .NET/ C# MVP ) - 07 Jan 2008 18:47 GMT
Hi,

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

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

> Help please!  .NET 2.0.
>
[quoted text clipped - 10 lines]
>
> Any ideas how this could be?
Don Gollahon - 07 Jan 2008 18:51 GMT
> 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.GetINISettings();
     try
     {
         string vstr = SharedClass.Params["LOGSERVER"].ToString();
     }
     catch (Exception E1)
     {
         MessageBox.Show("Main Params: " + E1.Message);
         throw (new Exception(E1.Message));
     }

And here is the GetINISettings method:

     private void GetINISettings()
     {
       if (System.IO.File.Exists(IniName))
       {
         FileStream vini = new FileStream(IniName, FileMode.Open);
         StreamReader vsr = new StreamReader(vini);
                 String[] elements;
         try
         {
             while (!vsr.EndOfStream)
             {
                 string vstr = vsr.ReadLine();
                 elements = vstr.Split('=');
                 SharedClass.Params.Add(elements[0], elements[1]);
             }
         }
         catch (Exception Ex)
         {
           vsr.Close();
           vini.Close();
           Environment.ExitCode = 9000;
           throw (new Exception("Config file not found or invalid: " +
Ex.Message));
           //MessageBox.Show("Config file not found or invalid.  " +
Ex.Message, "Error", MessageBoxButtons.OK);
           return;
         };
         if (vsr != null)
           vsr.Close();
         if (vini != null)
           vini.Close();
       }
     }

Signature

Don Gollahon

Ignacio Machin ( .NET/ C# MVP ) - 07 Jan 2008 20:18 GMT
Hi,

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

Signature

Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.

>
>> Hi,
[quoted text clipped - 52 lines]
>        }
>      }
Don Gollahon - 08 Jan 2008 00:43 GMT
> 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.

Signature

Don Gollahon

Don Gollahon - 07 Jan 2008 18:53 GMT
> 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.Params = new Hashtable();

Signature

Don Gollahon

Don Gollahon - 07 Jan 2008 19:06 GMT
> 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!

Signature

Don Gollahon


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.