January 2006 - Posts - Danie Bruwer

January 2006 - Posts

Some problems we had upgrading from 1.1 to 2.0
24 January 06 03:49 PM | danieb | 2 comment(s)

Some problems we had upgrading from 1.1 to 2.0 

  1. ASP 2.0 Websites
    1. Source Safe and *.pdb
    2. .aspx Pages (Inheritance and Partial Classes)
    3. Sub folders
  2. Windows Forms Tree Control

 

  1. ASP 2.0 Websites 

Although almost everything worked and compiled after upgrading via the wizard we still had a couple snags. There was the usual ambiguous namespace problems and a couple absolute menthods 

    1. Source Safe and *.pdb 

Some advice when adding a reference to a class library (another project in your solution):

You will notice that VS automatically determines which dependencies the project you are trying to add has and copies the appropriate dll’s and pdb’s to the web application’s bin directory. So then if you try to add the reference explicitly it gives you an error because it already exists. The trick here is to delete that dll and pdb manually and re-add it. 

So notice that all the dlls and pdb files that are not explicitly referenced by the project will be placed into sourcesafe which is the BIG PROBLEM. 

We found the easiest was to simply add the references in the correct dependency order.

    1. .aspx Pages (Inheritance and Partial Classes) 

Luckily our application only has about 10 .aspx pages so it could have been worse.

So if you have used a base page before (don’t confuse it with a master page) you will need to append this to the page directive.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EditItem.aspx.cs" Inherits="EditItem" CodeFileBaseClass="YourNameSpace.PageBase" %> 

You also have to ensure that both the classes are now partial classes.

public partial class EditItem : YourNameSpace.PageBase
and
public partial class PageBase : System.Web.UI.Page

  1. Windows Forms Tree Control 

This was a really difficult problem/bug to find. The exact same code ran 39 seconds in 1.1 and 10min in 2.0. So the first thing I did was to double check the code and since I am no expert on Windows Forms development everything seemed fine to me. So I asked Armand if he knows of a good profiling tool and he directed me to Ants Profiler which I must say I was very impressed with. 

Ok so what was the problem? You won’t believe it it’s the sequence in which you add tree nodes and set the properties. 

So coming from asp.net I have the habit of adding something directly after I have declared it like so. 

TreeNode node = new TreeNode();
root.Nodes.Add(node);
node.ImageIndex = (int)Images.folder;
node.Text = "bla";

The correct sequence is to only add the node after you have set the properties like so: 

TreeNode node = new TreeNode();
node.ImageIndex = (int)Images.folder;
node.Text = "bla";
root.Nodes.Add(node);

I am no expert on how the new Windows Forms Tree works but I am quesing that changing properties on a tree nodes after it has been added to the tree is trigerring some events which causes it to repaint/refresh or whatever.