Mar 31 2006

Netgear modem router doesn't like the onboard NIC

Category: IT RelatedRory Primrose @ 02:08

Back when I first got broadband, Optus set me up with an Alcatel SpeedTouch Pro which was a four port modem router. It seems that the modem part of it died during the week, so I went out to get a Netgear DG834 which is also a four port modem router.

Computers are supposed to make life easy, but no. Not this time. I hooked everything up and the desktop wouldn't connect to the new router. It could see that something was there, but was just couldn't get a connection happening.

I gave up on the desktop after a while and went with a laptop. This was fine. I then set up the Netgear wireless access point off the router and tested both the work and home laptops. Everything is looking good, except the desktop.

Now I have had a spare moment, I have chucked in a spare NIC into the desktop and it got a connection straight away. Looks like the onboard NIC and the Netgear router don't like playing together. Pity...

Tags:

Mar 19 2006

Site upgraded to Community Server 2.0

Category: IT Related | .NetRory Primrose @ 23:27

It has happened. This site is now running Community Server 2.0.

I did some initial testing locally before attempting to convert my site. This testing found some issues with the database upgrade script provided by Telligent. This was because their script was specifying a collation that wasn't compatible with my database. I edited their script (see attached file) to use the databases default collation and that sorted out the errors.

Once I had a chance to upgrade the site, it was reasonably painless. I had a few issues connecting to my database server using Enterprise Manager and to the web server over FTP. When those account issues were sorted, everything else went smoothly.

I used Ken Robertson's ExtendedUrlMapping dll to get the blog to appear at the root of the site. This was more reliable that the other methods indicated on the CS forums. The other methods didn't have correct url rewriting support for the RSS and ATOM links. I also changed SiteUrls.config to remove the Blogs link from the pages.

I think this is a really great product, but if you have an existing installation, run a test upgrade locally using a backup of your remote database with a local CS 2.0 setup. If you don't test before you attempt an upgrade, you are likely to have a painful experience.

Tags:

Mar 19 2006

Finally, a decent training session

Category: PersonalRory Primrose @ 06:00

I haven't done much training this year. We were in New Zealand for January, and for the last two months, I have helped with instructing on many of the nights that I would normally train. This has been because I was either a little sick and couldn't train or other instructors couldn't make it.

This weekend was the first decent training session that I have had this year. It was fantastic to do a decent workout and practise my patterns and sparring.

I am going to train with the advanced class now which should be really good as I will get more training per week than I have had previously. Really looking forward to it. This should also help me grade the next few levels very quickly as well. I hope to get to ChoDanBo (trial black belt) by the middle of the year.

Tags:

Mar 19 2006

I am ACE

Category: .NetRory Primrose @ 05:53

It has taken me several weeks to get around to this one. My ACE came in the mail. Very cool, but hard to take a photo of.

20060215-175339

Tags:

Mar 16 2006

Code conversion pitfalls

Category: .Net | IT RelatedRory Primrose @ 18:06

After doing four days of training and meetings in Brisbane, I am now back in the office reviewing some code. I had originally developed some web custom controls in VB (the organisations language of choice) that were then put into an architecture framework. This required that the code be converted from VB to C# which is the language of the framework involved. This work was done by another person while I was back in my prior UI design team.

Doing a code review of C# that is based on my VB code has put me in a new situation. Not having done this before, I am trying to think of scenarios that look safe, but are trouble under the surface. Turns out I found one very quickly. In this case, string comparisons are the danger. The VB code often had statements like this:

If sSomeValue = String.Empty Then

    ' Do something here

End If

VB is very forgiving with its string comparisons and it attempts to cover all the possibilities. If a straight language conversion is done, the same result does not occur in C#. To test this, I came up with a program in VB and in C#.

Here is the VB version of the program:

Public Class Form1 
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
  
        RunTests("""""", "") 
        RunTests("String.Empty", String.Empty) 
        RunTests("Nothing", Nothing) 
        RunTests("ThisValue", "ThisValue") 
  
    End Sub 
  
    Private Sub RunTests(ByVal sTestName As String, ByVal sTest As String) 
  
        Debug.WriteLine(New String("_"c, 50)) 
        Debug.WriteLine(String.Empty) 
        Debug.WriteLine("Testing string value " & sTestName) 
        Debug.WriteLine(String.Empty) 
  
        If (sTest = "") Then 
            Debug.WriteLine("Success: " & sTestName & " is equal to """"") 
        Else 
            Debug.WriteLine("Failed: " & sTestName & " is not equal to """"") 
        End If 
  
        If (sTest = Nothing) Then 
            Debug.WriteLine("Success: " & sTestName & " is equal to Nothing") 
        Else 
            Debug.WriteLine("Failed: " & sTestName & " is not equal to Nothing") 
        End If 
  
        If (sTest = String.Empty) Then 
            Debug.WriteLine("Success: " & sTestName & " is equal to String.Empty") 
        Else 
            Debug.WriteLine("Failed: " & sTestName & " is not equal to String.Empty") 
        End If 
  
        If String.IsNullOrEmpty(sTest) = True Then 
            Debug.WriteLine("Success: IsNullOrEmpty returns true for " & sTestName) 
        Else 
            Debug.WriteLine("Failed: IsNullOrEmpty returns false for " & sTestName) 
        End If 
  
    End Sub 
  
End Class 

I have missed out a test using vbNullString because it gets compiled as Nothing which is tested.

When this program is run, these are the results:

__________________________________________________

 

Testing string value ""

 

Success: "" is equal to ""

Success: "" is equal to Nothing

Success: "" is equal to String.Empty

Success: IsNullOrEmpty returns true for ""

__________________________________________________

 

Testing string value String.Empty

 

Success: String.Empty is equal to ""

Success: String.Empty is equal to Nothing

Success: String.Empty is equal to String.Empty

Success: IsNullOrEmpty returns true for String.Empty

__________________________________________________

 

Testing string value Nothing

 

Success: Nothing is equal to ""

Success: Nothing is equal to Nothing

Success: Nothing is equal to String.Empty

Success: IsNullOrEmpty returns true for Nothing

__________________________________________________

 

Testing string value ThisValue

 

Failed: ThisValue is not equal to ""

Failed: ThisValue is not equal to Nothing

Failed: ThisValue is not equal to String.Empty

Failed: IsNullOrEmpty returns false for ThisValue

VB has successfully evaluated whether a string has a value or not, regardless of whether the empty value is defined as a literal empty string, String.Empty or Nothing/vbNullString.

Here is the C# version of the program:

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Diagnostics; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
  
namespace WindowsApplication1 
{ 
    public partial class Form1 : Form 
    { 
        public Form1() 
        { 
            InitializeComponent(); 
        } 
  
        private void button1_Click(object sender, EventArgs e) 
        { 
            RunTests("\"\"", ""); 
            RunTests("String.Empty", String.Empty); 
            RunTests("Nothing", null); 
            RunTests("ThisValue", "ThisValue"); 
        } 
  
        private void RunTests(String sTestName, String sTest) 
        { 
            Debug.WriteLine(new String('_', 50)); 
            Debug.WriteLine(String.Empty); 
            Debug.WriteLine("Testing string value " + sTestName); 
            Debug.WriteLine(String.Empty); 
  
            if (sTest == "") 
            { 
                Debug.WriteLine("Success: " + sTestName + " is equal to \"\""); 
            } 
            else 
            { 
                Debug.WriteLine("Failed: " + sTestName + " is not equal to \"\""); 
            } 
  
            if (sTest == null) 
            { 
                Debug.WriteLine("Success: " + sTestName + " is equal to null"); 
            } 
            else 
            { 
                Debug.WriteLine("Failed: " + sTestName + " is not equal to null"); 
            } 
  
            if (sTest == String.Empty) 
            { 
                Debug.WriteLine("Success: " + sTestName + " is equal to String.Empty"); 
            } 
            else 
            { 
                Debug.WriteLine("Failed: " + sTestName + " is not equal to String.Empty"); 
            } 
  
            if (String.IsNullOrEmpty(sTest) == true) 
            { 
                Debug.WriteLine("Success: IsNullOrEmpty returns true for " + sTestName); 
            } 
            else 
            { 
                Debug.WriteLine("Failed: IsNullOrEmpty returns false for " + sTestName); 
            } 
        } 
    } 
} 

When this program is run, these are the results:

__________________________________________________

 

Testing string value ""

 

Success: "" is equal to ""

Failed: "" is not equal to null

Success: "" is equal to String.Empty

Success: IsNullOrEmpty returns true for ""

__________________________________________________

 

Testing string value String.Empty

 

Success: String.Empty is equal to ""

Failed: String.Empty is not equal to null

Success: String.Empty is equal to String.Empty

Success: IsNullOrEmpty returns true for String.Empty

__________________________________________________

 

Testing string value Nothing

 

Failed: Nothing is not equal to ""

Success: Nothing is equal to null

Failed: Nothing is not equal to String.Empty

Success: IsNullOrEmpty returns true for Nothing

__________________________________________________

 

Testing string value ThisValue

 

Failed: ThisValue is not equal to ""

Failed: ThisValue is not equal to null

Failed: ThisValue is not equal to String.Empty

Failed: IsNullOrEmpty returns false for ThisValue

Definately a different result. The reason for the difference is how the VB and C# code has been compiled down to IL.

Reflector shows the following for the VB program:

Private Sub RunTests(ByVal sTestName As String, ByVal sTest As String)

    Debug.WriteLine(New String("_"c, 50))
    Debug.WriteLine(String.Empty)
    Debug.WriteLine(("Testing string value " & sTestName))
    Debug.WriteLine(String.Empty)

    If (Operators.CompareString(sTest, "", False) = 0) Then
        Debug.WriteLine(("Success: " & sTestName & " is equal to """""))
    Else
        Debug.WriteLine(("Failed: " & sTestName & " is not equal to """""))
    End If

    If (Operators.CompareString(sTest, Nothing, False) = 0) Then
        Debug.WriteLine(("Success: " & sTestName & " is equal to Nothing"))
    Else
        Debug.WriteLine(("Failed: " & sTestName & " is not equal to Nothing"))
    End If

    If (Operators.CompareString(sTest, String.Empty, False) = 0) Then
        Debug.WriteLine(("Success: " & sTestName & " is equal to String.Empty"))
    Else
        Debug.WriteLine(("Failed: " & sTestName & " is not equal to String.Empty"))
    End If

    If String.IsNullOrEmpty(sTest) Then
        Debug.WriteLine(("Success: IsNullOrEmpty returns true for " & sTestName))
    Else
        Debug.WriteLine(("Failed: IsNullOrEmpty returns false for " & sTestName))
    End If

End Sub

Reflector shows the following for the C# program:

private void RunTests(string sTestName, string sTest)
{
    Debug.WriteLine(new string('_', 50));
    Debug.WriteLine(string.Empty);
    Debug.WriteLine("Testing string value " + sTestName);
    Debug.WriteLine(string.Empty);

    if (sTest == "")
    {
        Debug.WriteLine("Success: " + sTestName + " is equal to \"\"");
    }
    else
    {
        Debug.WriteLine("Failed: " + sTestName + " is not equal to \"\"");
    }

    if (sTest == null)
    {
        Debug.WriteLine("Success: " + sTestName + " is equal to null");
    }
    else
    {
        Debug.WriteLine("Failed: " + sTestName + " is not equal to null");
    }

    if (sTest == string.Empty)
    {
        Debug.WriteLine("Success: " + sTestName + " is equal to String.Empty");
    }
    else
    {
        Debug.WriteLine("Failed: " + sTestName + " is not equal to String.Empty");
    }

    if (string.IsNullOrEmpty(sTest))
    {
        Debug.WriteLine("Success: IsNullOrEmpty returns true for " + sTestName);
    }
    else
    {
        Debug.WriteLine("Failed: IsNullOrEmpty returns false for " + sTestName);
    }
}
The outcome of this is that for the "same" code to behave the same across both languages, using String.IsNullOrEmpty() is the safest way of determining whether a string as a value.

Tags:

Mar 7 2006

The security summit as it should have been

Category: PersonalRory Primrose @ 07:51

With all the self-importance that I can muster, I declare that the security summit that is working it way around the country just won't be as good as it could have been. That's right. I won't be able to make it.

I was going to be there and was very much looking forward to it. Going to the sessions, catching up with the boys etc etc. Not to be though.

Hi ho, hi ho, it's off to work (in Brisbane) I go.

Tis a shame. I was really looking forward to it...

Tags:

Mar 7 2006

Been there, done that, but better

Category: PersonalRory Primrose @ 06:10

My wife and I were around at the outlaws on the weekend to spend some time with family over good food and wine. My father-in-law came out with a funny one.

"Been there, done that, bought the t-shirt"

Maybe you had to be there, but I thought it was damn funny.

Tags:

Mar 3 2006

Pets put you in training for kids

Category: PersonalRory Primrose @ 14:56

I have heard quite a few times that pets are supposed to be good training for people who will have kids some time in the future. I think we had a moment like that yesterday.

My wife came home and drove her car into the garage. One of our cats walked in to the garage and decided that it wanted to get on top of the car, so it jumped. He almost made it. In an attempt to salvage what he could from his effort, he did what any cat would do. Unfortunately, claws don't come with a guarantee to provide grip on all surfaces.

We are the proud owners of a car with two new sets of claw scratches down one of the panels.

If this is training, kids must do some seriously bad stuff. What's the worst your kids have done? For that matter, what's the worst you've done as a kid?

Tags: