Blog Moved ....

ScottCate.com

community

frenz

my book(s)

my products

Check your try/finally blocks

A new Microsoft KB Article today in my kbAlertz.com newsletter points out a bug where both the if and else statements are executed in .NET 2002

This is worth checking your code. Basically you're looking for an if,else block, with a try/catch/finally or try/finally nested in the if statement, and the finally is blank. The empty finally block is the thing to look for.

The Link to the kbAlertz.com article is
http://www.kbalertz.com/Feedback_811324.aspx 

Below is the code they provide in the article.

1: class Test { 
2: public static void Main() {
3: object o = "test";
4: if (o is string) {
5: try {
6: Console.WriteLine("Test");
7: }
8: finally {
9: //Console.WriteLine("Finally.");
10: }
11: }
12: else {
13: Console.WriteLine("Shouldn't get here.");
14: }
15: Console.ReadLine();
16: }
17: }
18:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)