J
jehugaleahsa
Here is some ASP.NET C# code that does NOT work when ran on the
servers:
public Decimal CustomerKey
{
get { return get<Decimal>
(dataTable.DataTable.FK_CUSTOMERColumn); }
set
{
set(dataTable.DataTable.FK_CUSTOMERColumn, value);
}
}
For some reason, I get a NullReferenceException when the setter is
called. Now, I feel like an idiot because usually
NullReferenceExceptions are due to my own stupidity. I'm not saying
that's not the case here. Okay, but here is the weird thing... this
only happens on the server, and if I change the setter to this:
string message = String.Empty;
try
{
message += dataTable.ToString();
message += dataTable.DataTable.ToString();
message +=
dataTable.DataTable.FK_CUSTOMERColumn.ToString();
set(dataTable.DataTable.FK_CUSTOMERColumn, value);
}
catch (Exception exception)
{
while (exception != null)
{
message += exception.Message +
exception.StackTrace;
exception = exception.InnerException;
}
throw new Exception(message);
}
It will suddenly start working on the server! My guess was that
perhaps the dataTable was null, the internal DataTable was null or
that the column was null. Nope; they're all initialized! I even
checked inside the set method to see if it was the cause of the issue.
But depending on the code I write, the exception is thrown somewhere
different. I even had an exception occur on this line:
if (value == null)
where value is an object. How can that happen? @#$%^!
So, what would make my code blow up on a seemingly random line of
code? Some things allow to code work. Some things make it blow up on a
different line. It is almost like the library is being corrupted or
something.
I tried going line by line adding in exceptions deeper and deeper into
the code until they stopped. But that was like hitting a moving
target. Stranger, this same code has been working in production for
months and months. It also works on my development machine. I'm so
confused.
I think for now I am going to do a check sum on my DLLs to make sure
they are identical on my machine and on the server. I am running out
of ideas... and sanity.
servers:
public Decimal CustomerKey
{
get { return get<Decimal>
(dataTable.DataTable.FK_CUSTOMERColumn); }
set
{
set(dataTable.DataTable.FK_CUSTOMERColumn, value);
}
}
For some reason, I get a NullReferenceException when the setter is
called. Now, I feel like an idiot because usually
NullReferenceExceptions are due to my own stupidity. I'm not saying
that's not the case here. Okay, but here is the weird thing... this
only happens on the server, and if I change the setter to this:
string message = String.Empty;
try
{
message += dataTable.ToString();
message += dataTable.DataTable.ToString();
message +=
dataTable.DataTable.FK_CUSTOMERColumn.ToString();
set(dataTable.DataTable.FK_CUSTOMERColumn, value);
}
catch (Exception exception)
{
while (exception != null)
{
message += exception.Message +
exception.StackTrace;
exception = exception.InnerException;
}
throw new Exception(message);
}
It will suddenly start working on the server! My guess was that
perhaps the dataTable was null, the internal DataTable was null or
that the column was null. Nope; they're all initialized! I even
checked inside the set method to see if it was the cause of the issue.
But depending on the code I write, the exception is thrown somewhere
different. I even had an exception occur on this line:
if (value == null)
where value is an object. How can that happen? @#$%^!
So, what would make my code blow up on a seemingly random line of
code? Some things allow to code work. Some things make it blow up on a
different line. It is almost like the library is being corrupted or
something.
I tried going line by line adding in exceptions deeper and deeper into
the code until they stopped. But that was like hitting a moving
target. Stranger, this same code has been working in production for
months and months. It also works on my development machine. I'm so
confused.
I think for now I am going to do a check sum on my DLLs to make sure
they are identical on my machine and on the server. I am running out
of ideas... and sanity.