Thursday, November 4, 2010


Ok, so I'm a little late to the game here.  Generics came out with .Net 2.0, which was released back in 2005.  I've used them a good bit, but today I was asked what particular advantages Generics had over what was available in .Net 1.1, and, not having worked with .Net 1.1, I wasn't really sure.  So I did some digging and figured I'd share my results, for what it's worth.

In .Net 1.1, if you wanted to have a collection of objects, such as a linked list, a simple array-like list, a queue, or, in fact, if you wanted to make a class that made use of some object internally, but you wanted to make your data structure available to multiple internal types, you had several options, but they all had some significant limitations. 

Lets look at some examples.  Suppose, for instance, you wanted to create a queue class, where you could have a queue of int, string, or any other type such as car, pet, or person (other classes you need to define elsewhere).   Here are your options in .Net 1.1:

1. You could just use the generic 'object' type, as seen below.  The big disadvantage here is that you have to be very careful adding and removing items, because you could easily add an object of the wrong type and you wouldn't know until run time when you hit an invalid cast exception.

    public class Queue
        public void enQueue(object o) { ... }
        public object deQueue() { ...  }

2. You could create a intQueue class, a strQueue class, and so on.  The intQueue class would look like the code below.  You would get type safety, but the big disadvantage here is that anytime you want to create a queue of a new object, you have to create a new queue class, such as petQueue, carQueue, personQueue.  That's a lot of duplicated code, which increases maintenance time and you could easily end up with inconsistencies between your queue classes. 

    public class intQueue
        public void enQueue(int i) { ... }
        public int deQueue() { ... }

Enter .Net 2.0 and Generics.  In .Net 2.0, you can define your generic queue class as such:

    public class Queue<T>
        public void enQueue(T t) { ... }
        public T deQueue() { ... }

Notice that we use the generic placeholder of T.  T is whatever class you want it to be, but T is defined when you actually declare / instantiate an object of the Queue class.  Here is how you would make use of the class:

    Queue<int> myIntQueue = new Queue<int>;

Notice how we put 'int' in between the < > signs.  This signifies to the compiler that we are creating a queue of type int.  So if we take the queue of int and try to add a string to it, like this:


The compiler will throw an error, telling us that we can't add a string to a queue of int.

So there you go.  Generics give us the ability to generically (i.e., in a template sort of way) declare data structures that encapsulate other types without knowing what the type is that we are encapsulating, and they provide compile time type safety.

Saturday, October 16, 2010

Development Tools

I'm setting up a new development environment, and I thought I'd share the list of tools and technologies I'm putting into place there.  Please add any you'd recommend in the comments.  Everything here is free except the OS, SmartSVN, and RedGate SQL Source Control.
Operating System:   Windows Server 2008 R2 x64 ($$)
Application Server:  IIS 7 with .Net 4.0
Database Server:  SQL Server 2008 Developer Edition R2 x64 ($35)
(yes, that's right - Microsoft has a fully-featured version of SQL server for development that is dirt cheap)

Installation Tools used:
  • Web Platform Installer - tool to help install IIS, .Net, MVC, and other components
  • NuPack - helps to add extra assemblies / web.config merges, etc. for third party DLLs for your project

Thursday, October 14, 2010

Migrating Umbraco from MySQL to MSSQL

So you've been running the Umbraco CMS for a while on MySQL, but you've been told you need to move it to Microsoft SQL Server. Does it sound intimidating? It doesn't have to be. With the SQL script and instructions in this post, it's not too bad. First, let's start with an overview of the process.

1. Use the Umbraco installer scripts to create blank Umbraco tables on your SQL server
2. Set up a linked database in SQL Server to your MySQL database
3. Migrate the data (using my script below)
4. Update your web.config to point to the new database

Tuesday, September 7, 2010

SVN Trouble

(If all you want to do is solve the same problem, you only need to add a Timeout 1800 line to your c:\program files\visualsvn server\conf\httpd-custom.conf file and restart Visual SVN server - you can, of course, adjust the number of seconds as you like)

First off, if you are doing any kind of software development and you aren't using source control of some kind, you are missing out big time. I highly recommend source control. I use Visual SVN for the server and Smart SVN for the client, but there are lots of other great options out there. OK, on to the good stuff.

We have purchased licenses for RedGate's SQL Source Control, which allows you to use SQL Manager to check in SQL objects into a SVN repository. Very cool. I had been using this for a short while, and I soon saw this error when trying to scan for changes:

Could not read chunk Size: secure connection truncated


Having recently changed over to using a Droid Incredible, I'm having to rework some of my productivity tools to work with the Incredible. Part of that was finding a new GTD / Todo list app.

I had used OmniFocus on my Mac / iPod Touch, but ever since the iOS 4 upgrade, the only way to get it to sync is to wipe out the OmniFocus database on the iPod Touch and start over (My guess is that they updated their software to work with multitasking, and as a result it breaks with devices, like the iPod Touch 2G, that don't support multitasking on iOS4). Not a great solution. After waiting several months for a fix to this, I've given up and I looked around for something similar for my Droid. I strongly considered Remember The Milk, but the Mobile side of that app was rather weak.

I ended up settling on Toodledo. It needs some work on the ability to set custom filters, but overall it does the job I need it to do and it even has a widget for the Droid that shows my 'hotlist,', which is a huge help for me to quickly see the next 10 items on my list, color coded by priority.

Will I stick with it long term? I'm not sure. But so far I like it. I did spend a couple of hours transferring all of my todo items from OmniFocus to Toodledo the other night, so I'm committed to trying to make it work.

I use it to keep track of my grocery list, and I walk around with it at Kroger like a true geek, checking things off as I put them in my cart - my wife has had several good laughs at me as a result.

But I also use it to keep track of when to do maintenance on the cars and house, errands I need to run, etc. It's great to have a GTD tool that works on the web and syncs to my Droid.

Friday, July 2, 2010

Sharepoint 2007: 'Only their own' permission on Document Library - Update!

OK, after getting tired of manually setting this using Sharepoint Manager 2007, I decided to put together a solution. This solution provides a nice drop-down on the Document Library 'Security' menu like this:

And when you click on the 'Read/Write Security' link, you'll see this:

It looks and acts just like the page for standard lists - but this one also works for document libraries.

Download the solution from codeplex at

Wednesday, June 30, 2010

Sharepoint 2007: Picture Library limitations

In working with the Picture Library in Sharepoint 2007, I've run across 2 limitations:

1. No web part connections. For some reason Microsoft decided that Picture Libraries would never need web part connections. It's greyed out, as seen here:

2. Picture Libraries do not have the option to give users permissions to only view the pictures they created (and not view pictures that other users created). You can do this on non-document, non-picture library lists. Here is what it looks like on the 'Advanced Settings' page for a list:

But you don't get that on a picture library.

Thursday, June 17, 2010

Sharepoint 2007: 'Only their own' permission on Document Library

In Sharepoint 2007 you have a great permission you can set: 'Only their own'. This allows someone to view and edit only the items that they have created, and not other items that other people have created. Administrators of the site can see everything, of course.

This is easy to set on a List under the list settings. However, if you are using a Document Library, the setting is nowhere to be found. It is there, but it's hidden.

To change this setting, you can either write some code, as described here, or you can do the equivalent with Sharepoint Manager (make sure you get the 2007 version). Open Sharepoint Manager (while logged into your Sharepoint Server), drill down to the Document Library you are interested in, and you should see the 'WriteSecurity' setting. Change it to 2 to effectively set it to 'only their own.'

However, keep in mind that this only changes what the user can do via the UI. If they get to the list data via web services or some other method, this won't prevent them from getting at other people's data.

Friday, May 28, 2010

Passing a table using Nav Automation

I just had someone comment on my previous blog post asking how to pass a table using Nav Automation. Great question.

You can pass complex objects using Nav Automation, but only ones that you define (or that have been explicitly written to work with COM). This means that you can't pass a DataTable object, but you can create your own implementation of a DataTable object and pass it.

In your complex object, you have to explicitly define every property and method that you need to call on that complex object and surface those properties and methods through COM.

Tuesday, March 30, 2010

x does not contain a definition for y

I just ran across this problem... again... and because I didn't note the solution last time I had to figure it out again. It's so simple - but so hard to remember. Let's hope that next time I hit this I'll at least remember that I blogged about it. Here we go.

I'm building a web site, and it makes use of some DLLs that come from some C# libraries I've built. Over the course of time, I've added some functions to the libraries that I use in my website. And the website picks up the new functions and everything is great.

Then one day I come along and try to build the website in Visual Studio, but it gives me an error because it says that one of the newer functions in my library is missing. Here's the error:
className does not contain a definition for functionName
Hmm. I check the other project (which lives in the same solution), and the function is there. So I go to my web control, which is generating the error, I right click on the function name, and click 'Go to Definition', and sure enough, it jumps right to the function.

After a couple of hours of removing pieces and parts from different projects and trying to narrow things down, all without any avail, a thought finally hits my brain. The GAC!

Sure enough, an older version of my library somehow ended up in the GAC. I removed it from the GAC, then everything built just fine.

FYI, to remove a library from the GAC, browse in windows explorer to c:\windows\assembly, right click on the dll you want to remove, and click 'uninstall.'