Wednesday, February 29, 2012

Windows 8 Consumer Preview Released

If you have not already read the latest news updates from Microsoft, they have just released the Windows 8 Consumer Preview.  The Windows 8 Consumer Preview has incorporated numerous new features compared to the earlier Windows 8 Developer Preview available only to MSDN Subscribers.

You can download the Windows 8 Consumer Preview from here:

Reseeding the Identity key

If you have ever worked with database tables containing an Identity key, you probably already know that there is a high tendency for Identity keys to get missed as part of various insert operations (particularly with bulk uploads).  The easy way to get out of this, of course, is to NOT use Identity keys and thereby define your own sequencing for the database table.

But, then again, if you define your own sequencing, that is another hassle that you have to deal with by ensuring that every column that you insert as part of a bulk upload operation has a unique identifier associated with it.  Since you do not have to do this while using Identity keys, Identity keys are much more convenient.

Fortunately, there is a way to get the best of both worlds even while using Identity Keys.  If your Identity Keys happen to get out of sequence (as they almost always do), you can simply RESEED the Identity key.

What does that mean?  It just means that you can get the Identity key to pick up where it last left off.  So if a number was missed in the process of a bulk upload operation, you can simply delete the offending records and reseed your table to start at the missed number.  For example, if you run a bulk upload operation and somewhere along the line, the numbers 14 and 15 get missed as part of the load operation, you can simply run a delete command to delete all numbers greater than 13, reseed the identity key and then re-load all of the remaining records!

So just how do you RESEED the Identity key?

You just use the following command: DBCC CHECKIDENT ("Person.AddressType", RESEED, 13);

Since the last number that was successfully inserted was 13, you set the RESEED value to 13 so that the subsequent insert will begin inserting at 14 (13 + 1).

That's all there is to it!

If you want to read more about the DBCC CHECKIDENT command, you can read about it here:

Allowing Table Design Changes in SQL Server Management Studio

In SQL Server 2008 and above, there is a new setting which is configured by default which prevents any changes from being saved to the database that require dropping and re-creating the table.  Each time I install a new instance of SQL Server 2008 or SQL Server 2008 R2, I usually forget about changing this setting UNTIL the time I actually have to make a design change and receive the error message while attempting to make my change.

If you have encountered this error in the past, you probably have already had to solve this problem.  However, if you are relatively new to SQL Server, you may not yet know about this setting.

Below are the steps to allow these Design changes:

  1. From within SQL Server Management Studio, open up the Tools menu
  2. Click on the Options menu item
  3. Click on the + icon to expand the Designers section in the left hand pane
  4. You should see an option in the right hand pane that states "Prevent saving changes that require table re-creation" that is already checked by default.
  5. Uncheck the checkbox and click the OK button.
  6. You should now be able to apply any changes that you need in Design view!

Sunday, February 26, 2012

Publishing VSIX Project or Item Templates in a specified Category

If you are creating a VSIX Project and adding your individual Item or Project Templates to your VSIX Project, you probably have noticed that the default behavior of the VSIX Project is to simply publish the Item or Content Template at the root of the targeted language such as C#.

However, many Project Templates or Item Templates will be targeted towards specific categories or project types such as "Web", therefore, you will want to ensure that this categorical information displays when you install your VSIX Project as well.

Fortunately, the solution to achieving this is quite simple:

When you Add Content to your VSIX Project (such as your previously created Project or Item Template .zip file), there is a text field that states "Add to subfolder (optional)".  If you enter a directory path in this field such as /CSharp/Web, the appropriate folder structure will automatically be created for you as the content is added.

The result, as you can probably already guess, is that the installation of the VSIX project successfully publishes your Project or Item Template in the appropriate category!

Getting to know Visual Studio Template Replacement Parameters

If you have been working with creating your own custom Project or Item Templates in Visual Studio, you may find many of the replacement parameters confusing (at best).

There are numerous replacement parameters available, but the most common ones that you will use while creating your Project and Item Templates are listed below:
safeitemrootname Most often used with files that may span several files such as a WCF Servce
safeprojectname Most often used in Web Applications
rootnamespace Most often used in Class Library projects for class files
classname  Used to dynamically create the class name in any class file including code behind files

There are actually many more available to use across all of your various projects as can be found documented here:

Interestingly enough, however, if you extract some of the Project and Item Templates that are included as part of the Visual Studio 2010 installation, you will encounter many more which are completely undocumented such as the use of codebesiderootname and codebesideclassname or even masterpage or pagecontent.

As you dig further into creating your own Item and Project Templates, the best source of reference for developing these will ultimately be what Microsoft has done itself in the creation of various templates used within Visual Studio.

The great thing about creating your own Item and Project Templates is that these can easily be shared with a development team to encourage re-usability and standardization of development throughout projects in your organization.  

Rather than have individual developers create brand new Visual Studio projects that need to be heavily customized, you can now export these templates and share them with your development staff so as to save them from all of this customization effort.  If you also participate in periodic code reviews, you can probably imagine how much nicer it will be to perform these code reviews when every developer is using the same set of templates to develop their projects and their code!

Saturday, February 25, 2012

Digest Verification Error when editing FederationMetadata.xml

If you have ever had to manually edit the FederationMetadata.xml file, you may encounter a Digest Verification Error message while attempting to use the modified file with the Federation Utility.

The root cause of this is that the FederationMetadata.xml file is signed with a Digital Signature to prevent tampering of the file.  Therefore, when you manually edit the file, the digital signature hash value will not match the original hash value contained in the file thus throwing the Digest Verification Error/Exception.

One of the solutions to resolving this problem is provided here:

You can basically remove the element beginning with ds:Signature and then run it through the Federation Utility wizard again.

Alternatively, you can completely re-generate the FederationMetadata.xml file as well using the Federation Metadata Generator tool.

However, a better alternative is to simply use the STS Federation Metadata Editor tool that can be downloaded from here:

You can then manually remove the ds:Signature element and then Load the Metadata into the editor and save the modified FederationMetadata.xml file. 

In addition, the latest Source Code changeset (changeset #96419) for this tool will automatically remove this element for you if a Cryptographic Exception is thrown, thereby allowing you to re-load the file, make your changes and save the new file!

Friday, February 24, 2012

Preventing Product Key Disclosure attacks

If you are not already familiar with Windows Product Key Tools, there are an abundance of them available such as Magical Jelly Bean Keyfinder and many others.

Of course, any user with administrative privileges on a workstation or a server can then execute this tool and they will suddenly have your supposedly secret Product Key!  If you do not currently have a volume licensing agreement for a KMS (Key Management Service) server and a KMS key, you will most likely have to resort to using a MAK (Multiple Activation Key).  While the KMS keys require re-activation with a KMS Server on a periodic basis (such as every 6 months), MAK keys do not have that same imposed limitation and restriction.  Therefore, this places your MAK keys at a very high risk of being disclosed and re-used elsewhere without proper permission and authorization.

Fortunately, the folks at Microsoft have a solution to workaround this problem.  Starting with Windows Vista/Server 2008, you can now run a Windows Command Line command to prevent Product Key Disclosure attacks.  This command essentially clears out the product key information from the registry thereby preventing Product Key discovery tools from functioning properly.

The command that you can run in a command prompt window is: slmgr /cpky

Interestingly enough, after you run this command and then attempt to run one of these Key Finder or Product Key tools, you will still be able to view a Windows Product Key, however, the product key is completely incorrect!  Many times it will simply return a series of a single character such as all B's.

Now you can protect your coveted Windows Product Keys with the peace of mind that it will not be easily revealed and re-used elsewhere (such as on a home PC) by any of your standard corporate users.

Thursday, February 23, 2012

Creating custom Visual Studio Item Templates

If you are using Visual Studio 2010, you probably know that you can easily create new Item Templates based on existing file by simply selecting File-->Export Template and using the Item Template option in the Wizard.

However, this quick and easy solution of creating Item Templates may leave quite a lot be desired in terms of customizing your Item Templates for future use.  The file names may not follow any standard conventions and things such as namespaces, class names, interfaces etc. may be exported as-is, thus providing limited re-usability.

Instead, what you will probably want to do is customize the content in the file prior to exporting the content as an Item Template.

Fortunately, there is a syntactical language available for providing just this type of functionality.  You can read more about this syntax here:

If you want to see some examples of how this syntax is used, you have to look no further than your own Visual Studio 2010 installation!

Beneath the Program Files directory, you should find the following directory structure:
Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\

Below this directory you will find Item Templates for all of the various Item Templates that ship by default with Visual Studio 2010.

Now, if you navigate into any of these directories (such as CSharp), you will find several subdirectories corresponding to the various Item Template categories you find while creating New Items in Visual Studio.

If you go into the Code Directory and the 1033 subdirectory (for the English language), you will find numerous .zip files.  Interestingly enough, all of the Item Templates in Visual Studio are simply represented as nothing more than .zip files!

Since they are just .zip files, you can examine any of them by using any number of Zip Extraction tools (including Windows Own Built-in Zip Utility that ships with Windows Vista and later).

For example, if I open up the file, I will find 2 files contained within:
  1. Class.vstemplate
  2. Class.cs
If I now open up the Class.cs file, I will see content such as the following:

using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;

namespace $rootnamespace$
    class $safeitemrootname$

The $<variable name>$ syntax is the internal substitution syntax that is being used to perform the required namespace and class processing that occurs when you add a new Class file to your project. As you can see, this maps over to the Built-In Replacement parameters provided in the link above.

Finally, if you open the Class.vstemplate file, you will also be able to see how the Template Definition is created so that it may be used in Visual Studio.
In future articles, I will begin examining some of the additional nuances and details about creating and using  Visual Studio Item Templates, but for now, you should have enough to get you started towards creating your very own Item Templates!

Working with Telerik TeamPulse

If you are currently using Team Foundation Server 2010 and are a software development company, you probably already know that there is no easy way to collect feedback from your customers and incorporate or integrate that content into TFS Work Items.

Fortunately, the Telerik team has recently released software as an add-on to their TeamPulse to allow you to do just that!  It is called the Ideas & Feedback portal and is meant to allow customers to provide feedback regarding your product which can then be synchronized with your TFS Work Items.

If you are unfamiliar with setting this up in TeamPulse, below is the set of steps required to properly configure Team Foundation Server 2010 with your TeamPulse installation:

  1. If you do not already have a Team Foundation Server 2010 Team Project created, you will have to create one.  When you create the Team Project make note of the Team Project Template that you are using since this will relevant when you configure TeamPulse for TFS Synchronization.  If you have previously created a Team Project, hopefully you know which Project Template was used to create the Team Project.  Generally, most organizations use the MSF for Agile Project Team Template
  2. If you have not already done so, make sure that you have a user account which is configured as a Project Collection Administrator and a Project Administrator for the Team Project.  This information will be needed later when you configure TeamPulse for TFS Synchronization.  
    1. For the Team Project Collection, you can go into Team Project Collection Settings-->Group Membership
    2. For the Team Project Settings, you can go into Team Project Settings-->Group Membership
  3. Now, you can install and begin configuring TeamPulse.
  4. After installing TeamPulse, the first time you launch TeamPulse, you will be required to create a new TeamPulse project.
  5. While creating the new TeamPulse project, make sure you choose the EXACT SAME project template as was used for your TFS Team Project.
  6. After the TeamPulse project has been created, go into Settings-->TeamPulse Settings
  7. Enter the TeamPulse Host Url for your TeamPulse installation.  NOTE: If you do not do this, the TFS Synchronization WILL NOT WORK!
  8. Now, you will need to ensure that the Ideas & Feedback Portal will be available.  You can do this by going into Settings-->Portal Settings.
  9. Make sure that the Portal Visibility is changed to "Portal is Public"
  10. Now, to set up the TFS Sync Information, you can click on the Manage Sync Servers button also available from the Settings tab.
  11. Enter the Server Details for the TFS Server.  In addition, make sure that the user account that you configure for the Sync Server is a Project Collection Administrator for the specified Team Project Collection.
  12. After you have successfully added and saved the Sync Server information, you can click on the TFS Sync Information available from the Settings menu
  13. From the list of available Server/Collection, select and highlight the Server/Collection.  This will then display the corresponding available Team Projects within the Team Project Collection.  Also, select the corresponding Team Project you wish to use for synchronization.
  14. For the TFS Process Template, make sure that the selection in the dropdown list matches the Team Project Template that was used in TFS.  
  15. Once that information has been verified, you can click on the "Connect to Server" button below the TFS Sync Status label.
  16. If everything has been configured correctly, you should now be presented with a button displaying "Synchronize Now"
  17. Well, now it is time to actually create content from the Ideas and Feedback Portal and synchronize that content with TFS!
  18. From the Ideas & Feedback menu, click on the button for "Open Ideas & Feedback Portal"
  19. Once the Ideas & Feedback portal opens, you should be able to create new Feedback.
  20. You can search for existing items by typing some text in the search field, and if matching items are not found, you will be presented with a button to "Submit a New One".  Since this is a fresh installation of TeamPulse, go ahead and click on the "Submit a New One" button
  21. When creating a new item, you will be provided with the ability to categorize your suggestion as an Idea, Feedback, Feature Request or Problem.
  22. After you have entered some details for the Feedback item, go ahead and click the Submit button.
  23. Now that you have entered a Feedback item, you need to map the Feedback item to a TFS Bug or User Story.  You can do this via Ideas & Feedback-->View Ideas & Feedback.
  24. You can then click on the Edit icon next to each of the Feedback items (looks like conversational bubbles) and then either create a New User Story/Bug or Link to an existing User Story/Bug
  25. Once that is done, you can return to the TFS Sync Information screen (under Settings-->TFS Sync Information)
  26. Below the section for "What Am I Syncing", you should see the newly added Feedback item you just created through the Ideas & Feedback Portal.
  27. Check the Sync checkbox next to the Feedback Item.
  28. Now click on the Synchronize Now button to synchronize the items with TFS.
  29. If the items were able to successfully synchronize, you should now be able to see the items in TFS.  If you are using the MSF for Agile Team Project Template, you can view the newly synchronized items by clicking on Product Backlog, below the Team Queries item in Team Explorer.
  30. If you are now able to view the Work Items in TFS, you have successfully integrated Telerik TeamPulse with TFS!

Monday, February 20, 2012

Jetbrains TeamCity vs. Cruise Control.Net

There are numerous Continuous Integration Build Engines for .NET applications, including Microsoft's own Team Foundation Server Build Engine, but outside of TFS, two of the more common CI Build Engines are Jetbrains TeamCity and Cruise Control.Net.

Below are a list of some of the advantages and disadvantages of Jetbrains TeamCity over Cruise Control.Net (when running on the Microsoft Windows platform):


  1. Configuration is completely done through the Web User Interface.  No need to mess with XML configuration files such as ccnet.config.
  2. Very easy to create template build configurations by which other build configurations can be easily copied/cloned.
  3. Is maintained regularly and receives frequent updates (approximately every month or so)
  4. Great community forums and feedback mechanism to get new features incorporated into each release.
  5. Provides an easy way to configure "Build Steps" that function similar to a workflow in TFS Build.
  6. Provides the ability to perform Buddy Builds/Private Builds.
  7. Provides functionality similar to "Gated Check-In Builds" in TFS.
  8. Well documented
  9. Good support and maintenance of plug-ins
  10. Includes built-in tools such as dotCover for Code Analysis
  11. Can store build configuration information in a database such as SQL Server
  12. Exposes a Web Services API
  13. Provides an easy way to "Tail" the build logs as they are being generated
  14. Allows downloading the entire build log as a single .zip file
  15. Provides a Visual Studio plug-in for build integration with TeamCity
  1. Runs on an instance of Apache Tomcat rather than natively in IIS
  2. Built on Java, thereby, requiring Java development knowledge for plug-in development (rather than .NET)
  3. Free edition is limited to 20 build configurations
Based on the list above, you can probably guess that I highly prefer Jetbrains TeamCity over Cruise Control.Net.

What do you think?  Is TeamCity a better overall product than Cruise Control.Net?

Features missing in SharePoint 2010

Based on my experience working with SharePoint 2010, here are some of the features missing in SharePoint 2010:

  1. Generic Full Trust Proxy to call external Web Services (both SOAP and RESTful Services) from Sandboxed Solutions
  2. Drag and drop support for Workflow activities in SharePoint Designer
  3. Ability to bind to WCF RESTFul/WCF Data Services via BCS (Business Connectivity Services) in SharePoint Designer
  4. Ability to bind to Oracle databases via BCS (Business Connectivity Services) in SharePoint Designer (You can do this using Lightning Tools BCS Meta Man though:
  5. Ability to develop using .Net Framework v. 4.0
  6. Ability to support native SAML 2.0 Tokens (However, it looks like WIF will soon support SAML 2.0:
  7. Ability to support AND-based Claims for Security "Lives in USA AND lives in Michigan"
  8. Ability to support OpenSSO and similar solutions for STS Integration
  9. Ability to use Visual Studio 2010 to develop code behind for InfoPath Forms
  10. Ability to develop InfoPath Forms with .Net 3.5 or .Net 4.0 (currently restricted to .Net 2.0)
  11. Ability to easily Unit Test InfoPath Forms that contain code-behind
  12. Ability to use AJAX Server Controls in Sandboxed Solutions
  13. Ability to natively configure SMTP (such as for GMail SMTP) without relying on an external SMTP engine such as IIS
  14. Run security auditing reports out-of-the-box (without 3rd party tools)
  15. Support Excel Spreadsheet view without use of an ActiveX Control (thereby forcing usage of Internet Explorer for this feature)
Well, that's all the ones I have encountered thus far, but I am sure there will be more I will find along the way!

Friday, February 17, 2012

Dependent files in Visual Studio projects

If you have ever lost the hierarchical tree view in a Visual Studio project for a main file and its associated files, you probably already know that there is no way directly within the Visual Studio IDE to re-associate those files.  You may need to have this hierarchical tree view display particularly with the use of Config Transforms which are dependent on a primary Web.config file and its associated Build configuration transformation files.

Therefore, in order to do this, you will have to do the following:

  1. From within Visual Studio, right click on the affected project and select "Unload project"
  2. Once the project has been unloaded, you can right click on the project and select "Edit project"
  3. This will open the Visual Studio project for editing and display the MSBuild structure of the Visual Studio project file.
  4. If you are looking for a particular file such as Web.config, you can search for it.
  5. Once you find the appropriate element, determine if it exists as a standalone content item within an existing ItemGroup or if it is in its own associated ItemGroup.  If it is not within its own ItemGroup, you will need to remove the individual <Content Include="Web.config"> element and place in its own ItemGroup.  Visual Studio Intellisense will assist you in creating the new ItemGroup element.
  6. Once you have the Content item in the appropriate location, you need to add the dependency content items.
  7. A dependency content item will look like the following:

    <content include="Web.Debug.config">

  8. You can add each of these elements within the dedicated ItemGroup depending on the number of Config Transforms that you have for your project.
  9. Your final ItemGroup should look similar to the following:

        <Content Include="Web.config" />
        <Content Include="Web.Debug.config">
        <Content Include="Web.Release.config">

Integrating Classic ASP with ASP.Net Forms Authentication

If you are still running applications that require Classic ASP, you may want to run them side-by-side your ASP.Net applications while you are in the process of upgrading or converting them completely over to ASP.Net.

You can do that quite easily with ASP.Net Forms Authentication and Integrated Mode now available in IIS 7/IIS 7.5

You can learn more about how to accomplish this here:

If you want to get starting with your own Classic ASP application using ASP.Net Forms Authentication, there is a convenient Visual Studio Project Template I created available here:

Wednesday, February 15, 2012

ASP.Net Browser Detection

If you are using a version of ASP.Net older than ASP.Net 4, chances are that your browser detection for browsers such as Google Chrome is not accurate.  Effectively, in ASP.Net 3.5 and earlier, Google Chrome is detected as AppleMAC-Safari which makes it virtually indistinguishable from Apple's own Safari browser.

Fortunately, in ASP.Net 4, this has been remedied.  If you use the Request.Browser properties to detect differences between Google Chrome and Apple Safari, you can accurately detect the differences and correct version numbers.

If you would like to incorporate the new ASP.Net 4 browser definition files into your own ASP.Net 3.5 application, you can get these files from here: 

Tuesday, February 14, 2012

Multiple version testing of Internet Explorer

If you have looked at recent statistics for Internet Explorer usage globally, you probably already know that the usage of Internet Explorer varies widely.  Some users are still using Internet Explorer 6 while others are using anything from Internet Explorer 7 all the way through Internet Explorer 9.  In addition, Internet Explorer still largely dominates the market even with the widespread popularity of Mozilla Firefox and Google Chrome.

Therefore, you will probably need to test your web site in multiple versions of Internet Explorer to ensure compatibility across all of the various browser versions.

Fortunately, Microsoft has released a set of VPCs (Virtual PCs) to allow testing all of these various versions.  You can download these VPCs here:

You will need Virtual PC 2004 or Virtual PC 2007 installed on your host operating system (depending on your host OS version) to be able to run these individual VPCs.

Unfortunately, the reality of the market is that not every user has upgraded to a more modern browser, but fortunately, with the use of these VPCs, testing against these various environments should be a bit easier.

Friday, February 10, 2012

SQL Server Slipstreaming

If you looking for an easy way to slipstream Service Packs and Cumulative Updates into SQL Server 2008, you can find a very convenient tool to accomplish this on CodePlex called SQL 2008 Slipstream Assist.

The tool can be downloaded from here:

Here is an article on how to manually slipstream SQL Server 2008:

If you want to know how to slipstream Service Packs and Cumulative Updates into SQL Server 2008 R2, there are some good articles on doing this here: