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?
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?
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