Thursday, March 07, 2013

SortedSet with duplicate key.

Found a not so expected behavior of SortedSet today.

I did a custom class as such:

        public class MyClass : IComparable
            public string Title { get; set; }
            public string FileName { get; set; }

            public int CompareTo(MyClass other)
                int intTitleCompare = String.CompareOrdinal(this.Title, other.Title);
                return intTitleCompare;


The initial implementation is to use a SortedList/Dictionary and use the Title as key, but it will failed due to my data set having the same Title for multiple files. Thus with the above code, I'm expecting to be able to use SortedSet to have a sorted list of MyClass object while having the "key" being duplicates in the list.

So that did this:
var listOfFiles = new SortedSet();
                listOfFiles.Add(new MyClass()
                        Title = "cs",
                        FileName = "1.xml"

                listOfFiles.Add(new MyClass()
                        Title = "cs",
                        FileName = "2.xml"

The listOfFiles return me count of 1 instead of 2! This is because the CompareTo function returns 0, and SortedSet will ignore the entry during add.

Wednesday, November 04, 2009

Problem uninstalling Visual Studio 2008

My Visual Studio 2008 Trial came to an end today, as it is the trial Team system, I have to remove it and install the professional version that I have licensed to. But the running the "Remove/Configure" uninstaller doesn't work, it will always failed and no reason given.

Then I found this tool to remove after googling:

And further down the road, I hit another error which says:
Error1310. Error writing to file: C:\Config.Msi Access denied

And no matter what I do, setting the permission doesn't work.
Then I figure out that other users are having some problem if they have the software carbonate installed, which is a file backup software.
So I disabled my iDrive services, and voila, it works!

Hope this helps!