Change Internet Explorer default editor for View Source

I’m currently running IE 8 on a windows 7 machine. When I select “View Source” from the browser, Notepad is open. In IE 8 this editor is lot better then in previous version.   But I like NotePad++ as my default editor. In previous versions of IE I had to edit the registry to make NotePad++ the default view. In IE 8 the registry changes do not seem to work. 

To enable NotePad++, or any editor, to be the default for View Source, you must open Developer Tools.  The Developer tools can be open by the F12 key or the Tools menu (see image blow).


Once you have Developer Tools open, select “File” –> “Customize Internet Explorer View Source”.  Here you can select the Default Viewer, Notepad or other.


If you select other, a dialog will be presented for you to select the application you want as the for View Source


Error when opening Visual Studio 2008 project in Visual Studio 2010

The error I receive when trying to open Visual Studio 2008 project/solution in Visual Studio 2010 is “cannot be opened because its project type (.csproj) is not supported by this version of the application.” and “To open it, please use a version that supports this type of project”


I found a few link to this issue but they all refer to opening a Visual Studio 2005 project in 2008.  Since I couldn’t find an answer pertaining to VS 2010, I decided to use the solutions that I found for 2008. 

All the solution I found mention running this command “devenv.exe /resetskippkgs”.  So I open the Command Prompt and navigated to “C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDE” and ran “devenv.exe /resetskippkgs”.  This seem to fix the issue.  Visual Studio 2010 started and I receive the usual notification when opening a 2008 project in 2010.


I still have problems in all addition attempts to load 2008 project in Visual Studio 2010, I still need to go through this same process.


Default Enable Quick Edit for Windows Command Prompt (Console)

It seems that I’ve used Windows and the Command Prompt (Console) for ever and I never new of this feature.  Every time I wanted to copy or paste from the Command Prompt I had to right click and select “mark” or “paste” in the the window or click and bring up the menu.  It’s not that big of a deal, but saving 2 clicks or keystrokes adds up in 10 years.  I’ve must have wasted at least 30 minutes.   Here are my steps to set Quick Edit Mode as the default for the Command Prompt.

I know the following steps work for Windows XP and Windows 7.

The following screen show how to change the options for Command Prompt that is currently open.  When you close the Command Prompt this option is not saved, so the next time you open the Command Prompt this option will need to be reset.


The following image shows how to change the default configuration so that Quick Edit Mode is enabled by default.


TechNet – QuickEdit –

Unexpected results with Lambdas and Creating New Threads in C#

Today I was creating a simple application that needed to read from a queue and send XML to a web service.  It seemed to me to be a perfect opportunity to create a multi-threaded application.   Since I needed to send multiple properties to a method, I would use the Thread class and pass in a lambda expression.   Everything seem to be working fine, but I saw some strange things going on;  duplicate data was being sent to web service, even though the queue did not include duplicate data.  After a bit of debugging, I noticed that my call with the Lambda expression was passing the same data.  I did a little research on this issue and found this document, Closing over the loop variable considered harmful.   There’s a lot of technical info at this link, so I thought I would create a more simple example that would demonstrate this issue.

In this example I create a list of numbers and display these numbers to the console.  There are two individual foreach statements that loops through the numbers.   The first foreach does nothing special; it just calls DoWork.  All DoWork does is accepts an int and displays the number in the console.  Also DoWork has a sleep method to simulate a long running process.

The second foreach also calls DoWork, but calls DoWork on a separate thread.  The thread that is created accepts a Lambda, which points to DoWork.  It seems everything should work fine, but when you look at the results for the second foreach the data does not look correct.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Lambda_Threading
    class Program
        static void Main(string[] args)
            List numbers = GetData();

            foreach (int number in numbers)

            foreach (int number in numbers)
                Thread thread = new Thread(() => DoWork(number));


        public static void DoWork(int number)
            Random rand = new Random();
            Thread.Sleep(rand.Next(200, 500)); //Simulate Work
            Console.Write(number + ", ");

        public static List GetData()
            List numbers = new List();

            for (int i = 0; i < 10; i++)

            return numbers;

As you can see the results of the second foreach is not correct. The same number is displayed multiple time.  For example 9 is displayed three times and the numbers 0, 1, 2, 5, and 7 is not displayed at all.  The numbers are not in order because of the random sleep time in the DoWork method.


To solve this problem, all that is needed is a temp variable to store the number from the for loop.

foreach (int number in numbers)
    int tempNumber = number;
    Thread thread = new Thread(() => DoWork(tempNumber));

Now the results are what I was expecting.  The second foreach includes each number once and there are no duplicate numbers.  Again, the numbers are not in order because of the random sleep time in the DoWork method.  Even if you remove the sleep, the numbers still may not be in order.



Simple Example – AOP – Policy Injection with Unity

This is just a simple example explaining the processes/patterns to implement them using Unity 2.0, Dependency Inject, Inversion of Control (Ioc), and Aspect Oriented Programming (AoP). One of my primary goals is to not over complicate these examples. The examples should show how to do one thing and one thing only, but could possibly show how to implement these process/patterns in multiple way.

In this entry I will create a very simple application that shows how to do dependency injection, Interception and Policy Injection using Unity 2.0.

I’m using Unity 2.0 which is part of Enterprise Framework 5.0, and have created a very simple example application to test implementing AOP through Unity Interception. I’ve read a few articles on the web of how to use Unity with Interception and Policy Injection, and believe the articles from Dino Espisto were very benefical in help me figure this stuff out.
MSDN – Aspect-Oriented Programming, Interception and Unity 2.0
MSDN – Interceptors in Unity
MSDN – Policy Injection in Unity

If you are not aware of AOP, one of the primis is that Cross Cutting functionality, such as Loggin, should not be included in your domain classes.  My example contains a very simple console application that inlcudes using Interception that is configured through the Fluent API and a Configuration file.  The example also shows how to do Policy Injection and also configured using Fluent API and Configuration file.

For a contrived rule, emails should not be sent where the email address ends with “”.  I have a class called EmailSerivce.  The EmailService is a fake, it doesn’t do anything other then sleep and print a message to the console.   I do not want to add any code to the EmailSerivce class that validates email; this should be handel by Unity Policy Injection.
Continue reading “Simple Example – AOP – Policy Injection with Unity”

Windows & Visual Studio Memory Limits

Tomorrow I will be receiving a new computer.  It has an Intel i7 920 processor and 6 gigs of a ram.  I plan on using Beta of Windows 7 64 bit, so I can take advantage of the full 6 gigs of memory.  A 32 bit operating system can only access 4 gigs.

This new computer will be an improvement that is far better then my current laptop.  My laptop has a Pentium 4 that runs at 3 GHz.  Running Visual Studio and other app on the laptop brings it to its knees.

So, tonight I was wondering how much memory I should have installed on my new computer to run Visual Studio.  Of course it’s a little late for this question, since I have already purchased the PC and it’s arriving tomorrow. But the new computer does have 3 ram slots available and the motherboard maxes out at 12 gigs. So I should have no problems upgrading

But back to the question of how much memory should I have installed for Visual Studio.  If you are like me, while programming I usually have many applications running in the background.  These application could be resource hogs live SQL Server, Photoshop, or may IE windows or tabs open.  So I Googled “Memory needed for Visual Studio .net”. 

The first link was “Hacking Visual Studio to Use More Than 2Gigabytes of Memory”. This triggered a memory from the last company I worked at.  At this company our solution files contained many projects and those projects could be quite large.  Many times while compiling I would get the error “Not enough storage is available to complete this operation.” After reading the previous article, I learned that Visual Studio has a 2 GB limit, which was probably the reason for the storage error.   The article also mentioned that the Visual Studio is defaulted to 2 GB of maximum memory, but it can be increased.  Of course, on a 32 bit OS the maximum memory limit is somewhere less then 4 GB.  I’m not going into the details of why its less then 4 GB, but you can read this great article to learn more about it.

“Dude, Where’s My 4 Gigabytes of RAM?

I never came up with the amount of memory I need, but these articles listed above provided a lot of information and background on the hows and whys of getting the best performance out of my computer.

As usual, I blogged about this so that I have a reference to the information later, but I hope this give you some insight into 32 bit OS’s and Visual Studio.

Find Parent Table

I’m in the need of a function that will find the parent table based on a child table name and a column name.  The column should be a foreign key.  I tried to find a solution on the web, but couldn’t find anything.  I probably used the wrong terminology in the searches.  So this is what I have come up with.

'CREATED FUNCTION fn_GetParentTable'
FUNCTION dbo.fn_GetParentTable(
     @ChildTable VARCHAR(200)
     ,@ChildColumn VARCHAR(200)
     DECLARE @ParentTableName VARCHAR(MAX)
     SELECT @ParentTableName = Parent_Table_Constraints.Table_Name
     FROM Information_Schema.Table_Constraints Table_Constraints
     Table_Constraints.Constraint_Name = CONSTRAINT_COLUMN_USAGE.Constraint_Name
     INNER JOIN Information_Schema.Table_Constraints Parent_Table_Constraints ON
  REFERENTIAL_CONSTRAINTS.Unique_Constraint_Name = Parent_Table_Constraints.Constraint_Name
  CONSTRAINT_COLUMN_USAGE.Table_Name = @ChildTable
  AND CONSTRAINT_COLUMN_USAGE.Column_Name = @ChildColumn
  AND Table_Constraints.Constraint_Type = 'FOREIGN KEY'
     RETURN @ParentTableName

SELECT dbo.fn_GetParentTable ('tableName', 'ColumnName')


Sysinternals Utilities

This describes it better then I could
"The Sysinternals web site was created in 1996 by Mark Russinovich and Bryce Cogswell to host their advanced system utilities and technical information. Microsoft acquired Sysinternals in July, 2006. Whether you’re an IT Pro or a developer, you’ll find Sysinternals utilities to help you manage, troubleshoot and diagnose your Windows systems and applications. If you have a question about a tool or how to use them, please visit the Sysinternals Forum for answers and help from other users

Sysinternals Utilities Index

Sysinternals Suite
The entire set of Sysinternals Utilities rolled up into a single download.

v4.23 (December 19, 2008)
This update fixes a bug that sometimes caused AccessChk to not show the full list of rights and privileged assigned to a user account.

1.32 (November 1, 2006)
This simple yet powerful security tool shows you who has what access to directories, files and Registry keys on your systems. Use it to find holes in your permissions.

v1.01 (November 27, 2007)
Active Directory Explorer is an advanced Active Directory (AD) viewer and editor.

v1.01 (November 20, 2007)
An LDAP (Light-weight Directory Access Protocol) real-time monitoring tool aimed at troubleshooting Active Directory client applications.
Continue reading “Sysinternals Utilities”

Remove Multiple Spaces

I have a need to replace multiple space with a single space in varchar during a SQL statement.
On the web there were many solutions, but these two seemed to be the more simple ones.


@strValue VARCHAR(MAX)

SET @strValue = sf    ds     fds f fds fd sf    ds    


CharIndex(‘  ‘, @strValue)>0


@strValue = Replace(@strValue, ‘  ‘, ‘ ‘)




@strValue VARCHAR(MAX)


@strValue = ‘     sf ds fds f ds       fds         fd sf ds ‘


LTRIM(REPLACE(REPLACE(REPLACE(@strValue,‘  ‘, ‘ ‘), ‘  ‘, ‘ ‘), ‘  ‘, ‘ ‘))

Removing unwanted spaces within a string …
Squeeze Function

Entity Framework

 ADO.NET Entity Framework
Introducing ADO.NET Entity Framework(By Julia Lerman) 
MSDN Quickstart (Entity Framework)
ADO.NET Entity Framework
Additional MSDN Links
The following topics enable you to learn more about the Entity Framework:
          Additional Entity Framework Resources

Provides links to conceptual topics and links to external topics and resources for building Entity Framework applications.

          Getting Started (Entity Framework)

Provide information about how to get up and running quickly using the Quickstart (Entity Framework), which shows how to create a simple Entity Framework application.

          Quickstart (Entity Framework)

Shows you how to use the Entity Data Model tools with Visual Studio 2008 to quickly create your first Entity Framework application.

          Application Scenarios (Entity Framework)

Provides task-based links to topics that match specific application scenarios, such as writing queries, binding objects to data controls, or implementing business logic.

          Entity Framework Features

Provides more detailed information on the features that compose the Entity Framework and links to topics that discuss those features.

          Entity Framework Terminology

Defines many of the terms that are introduced by the EDM and the Entity Framework and that are used in Entity Framework documentation.

          Tons of “How Do I?” Videos — Data Platform Development
Why use the Entity Framework
A decent blog that discusses LINQ to SQL, Tradiontal ADO.NET, and NHibernate.
Entity Framework Q&A
EntityClient + Entity SQL
Object Services + Entity SQL
Object Services + LINQ
Introducing the Entity Framework (by Shawn Wildermuth)
Julie Lermans Blog( author of Entity Framework)
MSDN Webcast: MSDN geekSpeak: Julie Lerman on ADO.NET (Level 200)
Julie does a great job of presenting EF.  She has a book called Programming Entity Framework, which is an O’Reilly press book, that is schedule to be released January 15, 2009.
dnrTV – Dan Simmons on The Entity Framework Part 1
dnrTV – Dan Simmons on The Entity Framework Part 2
LINQ to Relational Data: Who’s Who?
LINQ to SQL; LINQ to Entities
Entity Framework- The Crib Sheet
ADO.NET Entity Framework Essential Resources  October 2008