views:

363

answers:

2

I have a List in a web control when the control creates it's child controls I perform a foreach loop through the list of fields as

foreach (IField field in this._fields)
{
   /* Do some work here */
}

Localhost, out dev environment, and our staging environment everything is fine. But when we deploy to our dev cluster each "field" is null during the looping. What would cause these objects to be null? When i load this list from another list of data everything loads fine and that data is not null.

A: 

First check: How are you getting those fields collection? are you doing some as IField somewhere along the way? That will effectively give null if it doesn't implements IField.

If it isn't the above, it would be a really weird scenario. The only thing that comes to mind, was something really awful I saw in some clear code in an app developed by another provider:

void Clear() { //some normal code to clear info on some controls myTextBox = null; anotherTextBox = null; }

While there is no point in doing so, it actually causes trouble with asp.net. On some specific postback scenarios, asp.net failed with a nullreferenceexception during part of some internal parts of its lifecycle.

So, also check if there are some weird routines assigning null to controls declared on the page.

eglasius
+1  A: 

Make sure you're not using the Application level cache in your app to store the contents of your IFields, since it is not replicated across the servers in a cluster.

If you're using Session cache, again, make sure it's persisted to SQL Server when running in the cluster. If it's an in-process Session cache, it is unique to each server in the cluster (Similar to the Application cache).

PeterR