Blogging Efforts

I have decided to start contributing to my companies Blog on Microsoft Technologies. They will require me too post more frequently.  So if my past blogging efforts have been beneficial to you keep an eye on to see what I have too say. I will likely post references to the post here as well.


C# Pluralize and/or Singularize

Recently I had a need to Pluralize some data elements to be displayed on screen. I didn’t want to have to write my own logic to figure do I need an”s” or  and “es” as so on. So come to find out in .NET 4 there is a class that aids in this process “System.Data.Entity.Design.PluralizationServices.PluralizationService“. Also since I’m using VS2010 and .NET 4 I get the capability to add Extension Methods to existing types. I wanted to be able to easily call the Pluralize method from any Sting.

Here is the code for the Pluralize and Singularize Extension methods for the String type.

using System;
using System.Data.Entity.Design.PluralizationServices;
using System.Globalization;

public static class ExtensionMethods {
    public static String Pluralize(this String s) {
        return PluralizationService.CreateService(CultureInfo.CurrentCulture).Pluralize(s);
    public static String Singularize(this String s) {
        return PluralizationService.CreateService(CultureInfo.CurrentCulture).Singularize(s);

Now I can easily call the method on any String.


The “DeleteCurrentDeployment” task failed unexpectedly and IE8 tab hang

Thank you Roel van Lisdonk ( I have been having problems with my Visual Studio  2010 when building and running Windows Azure projects. I would get an error which I posted in the MSDN forums and also on StackOverflow and never received a solution to the problem. So I re-imaged my machine and re-installed everything.

Same issue occurred again.

Error 1  The "DeleteCurrentDeployment" task failed unexpectedly.
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease)
at Microsoft.VisualStudio.OLE.Interop.IServiceProvider.QueryService(Guid& guidService, Guid& riid, IntPtr& ppvObject)
at Microsoft.VisualStudio.Shell.ServiceProvider.GetService(Guid guid, Type serviceType)
at Microsoft.VisualStudio.Shell.ServiceProvider.GetService(Type serviceType)
at Microsoft.Cct.IServiceProviderExtensions.GetService[InterfaceType,ServiceType](IServiceProvider serviceProvider)
at Microsoft.Cct.CctBuildDeploymentTaskHost.DeleteCurrentDeployment()
at Microsoft.CloudExtensions.MSBuildTasks.DeleteCurrentDeployment.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

So I removed the “DeleteCurrentDeployment” task from the targets file and then i was able to build. When i went to run the project in debug i was prompted with a smaller version of the error.

Windows Azure Tools: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6D5140C1-7436-11CE-8034-00AA006009FA}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

After I searched for that error I again came across a blog post from Marc Valk, which then pointed me to another blog post from Roel van Lisdonk. Come to find out that the IE8 hang issue which i was also having was created by SourceGear Vault 3.1.9 which i happened to be running for my VS2005 projects. So i followed the instructions given by Roel van Lisdonk.

1. Install the SourceGear Vault client v3.1.9 in “C:\Program Files (x86)\SourceGear\Vault Client”
2. Backup all files and folders from the folder “C:\Program Files (x86)\SourceGear\Vault Client” to a backup folder “C:\Program Files (x86)\SourceGear\Vault Client Backup”
3. Uninstall the SourceGear Vault client v3.1.9
4. Restore all files and folders from the “C:\Program Files (x86)\SourceGear\Vault Client Backup” to the “C:\Program Files (x86)\SourceGear\Vault Client”
5. Create a FixSourceControlProviderOnWin7x64.reg file and paste the following values:

Windows Registry Editor Version 5.00
"ProviderRegKey"="Software\\SourceGear\\Vault Client"
"SourceGear Vault Client"="Software\\SourceGear\\Vault Client"
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SourceGear\Vault Client]
"SCCServerName"="SourceGear Vault Client"
"SCCServerPath"="C:\\Program Files (x86)\\SourceGear\\Vault Client\\VaultIDE.dll"

6. Run the FixSourceControlProviderOnWin7x64.reg file.

Sure enough this solved both of my problems. Just wish I would have found this out before I did the re-image :). Talk about killing two birds with one stone.

Whether I get feedback or not I’m going to start using to post all the events I will be speaking at. You can find most of my past events here ( I will be posting all my upcoming events as they are finalized.  If you have been to any my talks please give feedback.

This site will make it easier for me to track my events.

SSRS 2008 Generate Calendar(s) based on a date range

I’m finally able to start blogging again. In addition to my Simple-Talk article I figured my first post would be an updated calendar report based on employee birthdays in the AdeventureWorks Database. Using recursive common-table-expressions I was able to generate the records needed to build a calendar for a given date range. Here is a link to the article ( to give you a basic idea of what the query is doing to generate the data as well as an example of how to build the report .

Here is the updated query:

--DECLARE @StartDate DATETIME = '03/26/2009', @EndDate DATETIME = '03/26/2010'
SELECT @StartDate = DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0)) --FirstDayOfMonth
SELECT @EndDate = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@EndDate)+1,0)) --LastDayOfMonth

; WITH Months AS (
	 [Month] = DATEPART(MONTH,DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0))),
	 [Year] = DATEPART(YEAR,DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0))),
	 FirstDayOfMonth = DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0)),
	 LastDayOfMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@StartDate)+1,0)),
	 FirstDayOfCalendar = DATEADD(DAY,-DATEPART(WEEKDAY,DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0)))+1,DATEADD(s,0,DATEADD(mm, DATEDIFF(m,0,@StartDate),0))),
	 LastDayOfCalendar = DATEADD(DAY,6-DATEPART(WEEKDAY,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@StartDate)+1,0))),DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@StartDate)+1,0)))
	 [Month] = DATEPART(MONTH,DATEADD(MONTH,1,FirstDayOfMonth)),
	 [Year] = DATEPART(YEAR,DATEADD(MONTH,1,FirstDayOfMonth)),
	 FirstDayOfMonth = DATEADD(MONTH,1,FirstDayOfMonth),
	 LastDayOfMonth = DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,DATEADD(MONTH,1,FirstDayOfMonth))+1,0)),
	 FirstDayOfCalendar = DATEADD(DAY,-DATEPART(WEEKDAY,DATEADD(MONTH,1,FirstDayOfMonth))+1,DATEADD(MONTH,1,FirstDayOfMonth)),
	 LastDayOfCalendar = DATEADD(DAY,6-DATEPART(WEEKDAY,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,DATEADD(MONTH,1,FirstDayOfMonth))+1,0))),DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,DATEADD(MONTH,1,FirstDayOfMonth))+1,0)))
	 LastDayOfMonth < @EndDate
), Dates AS (
	 [Date] = FirstDayOfCalendar,
	 FilterDate = LastDayOfCalendar
	 [Date] = DATEADD(DAY,1,[Date]),
	 [Date] < FilterDate
), EmployeeBirthDay AS (
	 [Day] = DATEPART(DAY, e.BirthDate),
	 [Month] = DATEPART(MONTH, e.BirthDate),
	 [Year] = DATEPART(YEAR, e.BirthDate),
	 FullName = e.FirstName + ' ' + e.LastName
	 DimEmployee e
 DisplayOnCalendar = DENSE_RANK() OVER (ORDER BY d.Year, d.Month),
 [Day] = DATEPART(DAY,d.[Date]),
 [WeekDay] = DATEPART(WEEKDAY, d.[Date]),
 [Order] = DENSE_RANK() OVER (PARTITION BY d.Year, d.Month ORDER BY d.Date), 
 Dates d
 LEFT JOIN EmployeeBirthDay ebd ON ebd.Month = DATEPART(MONTH,d.[Date]) AND ebd.Day = DATEPART(DAY,d.[Date])


The earlier version of the report has been updated to  SSRS 2008. There is only a few changes that need to be made to get multiple calendars to display. Add a new tablix which is grouped by “DisplayOnCalendar” with page break after each group. Move the Month information from the report header into the new tablix as the group header. Drag the previous tablix into the details section on the new tablix. You can now remove the “Note” column from the previous tablix and update the value on the “Time” column to look at “FullName.” I made some additional format changes but won’t go in to details on those. Below is an example of what my report looks like before I preview it.

Once I preview the report I will show you the report which includes all the employees from AdventureWorks with their birthday in February 2010. The Date range I used is 03/26/2009 through 03/26/2010 so you will see there is 13 pages of the report to reflect the 13 months in the date range.

Here is a link to download the RDL file for the report above ( the zip file also contains the original RDL for the current month calendar report. The current month report is “Calendar.rdl” the updated version is “RangeCalendar.rdl” these reports will work with SSRS 2008 and the Adventureworks database.

10 Common SSRS Challenges

Check out my Article on

Create application Shortcut in .Net the easy way

Have you ever needed to create an application shortcut on the fly in your .Net application? Well I have and this is what I did. The easiest way to create a shortcut is to create a url file which contains a reference to your file instead of a web address. A url file is basically like an ini file. To create a real desktop shortcut requires the use of a COM object, which for my case was not needed.

A url file is a plain text file with the “url” file extension. Below is an Example of the required content of a url file:

There are other options that can be added to the url file as well, but all you need to specify is the URL. Rather than using a url to a internet location you can create one for a file on your system by setting URL to file:///c:/Temp/ReferenceFile.txt. Example of a url file content with additional options to specify the icon:
URL = file:///c:/Temp/ReferenceFile.txt
IconIndex = 0
IconFile = C:\Temp\application.ico

Here is an example of how to create the url file in C# using .Net 2.0:
using System;
using System.IO;
using System.Text;

public static class Program {
  public static void Main() {

  private static void CreateDesktopShortcut() {
    String appName = "Application.exe";
    String appDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    String shortcutName = "Application";
    String shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
    StringBuilder sb = new StringBuilder();

    sb.AppendLine(String.Format(@"URL=file:///{0}/{1}", appDirectory, appName).Replace(@"\", @"/"));

    File.WriteAllText(String.Format(@"{0}\{1}.url", shortcutPath, shortcutName), sb.ToString());

Reporting Services 2005 – Dynamic Parameter List

I have seen developers writing reports in Reporting Services and taking a lot of time adding a section to the report to list all the parameter selection(s) to be displayed in the report. To address this issue dynamically (my way) you will need your reports deployed to the reporting services server, and have access to the reporting services database. Here you will find some template reports which include the Dynamic Parameter List ( Reporting services stores everything about the report in the database back-end. Gain access to the back-end and you will be able to do all sorts of things. For instance maybe create a report of your complete catalog of reports or even write some report metrics by looking at the report Execution log.

Here is my Query for obtaining the report parameter information, from the reporting services back-end:
  [Order] = ROW_NUMBER() OVER (ORDER BY tmp.Name),
  ParameterName = Params.p.value('Name[1]','varchar(255)'),
  ParameterLabel = Params.p.value('Prompt[1]','varchar(255)'),
  DefaultValue = Params.p.query('DefaultValues/Value'),
  ParameterXml = Params.p.query('.'),
  ReportName = tmp.Name,
  ReportPath = tmp.Path
  (SELECT Name, Path, ReportParams = CONVERT(XML,Parameter) FROM dbo.Catalog WHERE Path = @ReportPath) tmp
  CROSS APPLY ReportParams.nodes('(Parameters/Parameter)') AS Params(p)
WHERE NOT Params.p.value('Name[1]','varchar(255)') IN ('ReportPath','ReportNumber')

The parameter “@ReportPath” is defaulted to “=Globals!ReportFolder + “/” + Globals!ReportName” this is how the report is referenced in the catalog.

Now that I have the parameter collection, I have a matrix control at the top of the report to display the parameters.  I am using some custom code to get my parameters to be displayed horizontally in a pre-determined number of columns:

Shared Function SetColumn(ByVal row As Integer, ByVal column As Integer) As String
  While row > column
    If column >= row Then Exit While
    row = row - column
  End While
Return row
End Function
Shared Function SetRow(ByVal row As Integer, ByVal column As Integer) As String
  Dim i As Integer = 1
  While row > column
    i = i + 1
    If column >= row Then Exit While
    row = row - column
  End While
  Return i
End Function

I group my rows using the two methods mentioned above, for instance if i want a 2 column list the columns group contains expression “=Code.SetColumn(Fields!Order.Value,2)” and the rows group contains expression “=Code.SetRow(Fields!Order.Value,2)”


The Templates in the zip at contain multiple features:

  • Horizontal Record display
  • Using Images in Page Header without causing Merged Cell issues in Excel
  • Templates for Landscape and Portrait you can build from
  • Dynamic Parameter List
  • Using Reporting Services database to your advantage
  • Using Custom Code in RDLs
  • Using Parent Groups and Padding based on levels
  • Using rectangles to create Page breaks so different section of the report when exported to excel display on separate worksheets

Reporting Services 2008 – Report Authoring

I just did my first Presentation for the LANUG group in Mobile, AL on November 18th, 2008! I started out a little nervous but things overall went well. Now that I got my first presentation out o the way I plan to do more in the coming years.

Check out the slide deck and demo reports here: