Thursday, May 15, 2008

VS .NET Code executing differently on different machines!

Not all .NET code are created equal?

Wait a minute, I thought the whole point of having a programming framework was to allow code to execute the same way and with ease regardless of the hardware! When I first got a bug report which basically indicated that the same program written in the same version of the .NET Framework executed differently (and produced numerous bugs) my first reaction was "IMPOSSIBLE!". But upon further testing and inspection I confirmed this issue or glitch as I like to call it.

The problem is not exactly that the same routine produces different results, but that due to a set of events firing in a specific order, the outcome of your code may be different on different machines.

Consider the following case. Suppose you have a .NET 1.0 application, that was later upgraded to .NET 1.1 (Visual Studio 2003). Some possible client machine configuration:

1. Having .NET 1.1 ONLY on a machine.

This is probably the ideal case for a .NET 1.1 Application. All built in events such as "Change" and "Validate" will fire as needed and everyone will be happy.

2. Having .NET 1.1 AND 2.0 on a machine side by side.

In some instances, depending on if the client machine has both .NET 1.1 and 2.0 installed, built in form events "SPECIALLY" Validation routines were found to fire when there was no reason for them to fire (i.e. no data was changed to cause a Validation routine to fire, but a Validation fired on several text boxes and combo boxes while changing tabs in a tab control unrelated to either of the two!

The closest thing to an answer that I was able to find to this issue was that even though your application was written to use .NET 1.1, the .NET CLR still chooses the CLR of the higher version of .NET for some Windows Form related events. It just so happens that the developers who wrote this application also had both .NET 1.1 and 2.0 installed on their machine, as well as the QA staff that QA Tested the application. When the application was deployed to the field, several user machines which were Thin-Client machines were not able to run both .NET 1.1 and 2.0 side by side (due to hardware limitations), which resulted in the above set of bugs.

So watch out for this one people, because it is VERY hard fix bugs like this! I would love to hear from other people who have run into this issue, so if you have anything to add to this, please let me know!

Pete Soheil
DigiOz Multimedia

No comments: