Programming and Technology blog

Workaround for Installing KB Article KB971092 successfully

In some cases there is an issue with installing the following update “Security Update for Microsoft Visual Studio 2008 Service Pack 1 (KB971092)”.  The workaround to properly install the update you must set the security on the files vsvars32.bat and vcvarsall.bat to allow the local Users group write permission on those files.  I am not sure why this is an issue but from reading other posts and such on the issue most of the affected people do not have vc++ installed.

They can be found in the following folders:


  • C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
  • C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat


  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat
  • C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat

VS 2008 - Duplicate Toolbox Items

I opened up VS 2008 the other day and noticed that there were multiple instances of the same toolbox item listed (e.g. there were 4 Button controls listed).  I tried to reset the Toolbox but nothing seemed to solve the problem.

The fix was to close VS and delete the 4 *.tbd files located @ C:\Documents and Settings\USER_NAME\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ (under XP / Win2k3) or C:\Users\USER_NAME\AppData\Local\Microsoft\VisualStudio\9.0\ (under Vista / Win2k8 / Win7)

Upon restarting VS seems to rebuild these files and fixed the issue.  Not sure why this happened and seems nobody else does either.

T4 Template lovin'

The following is a couple of T4 templates that I have been fooling around with in my spare time (sharing the time between jQuery, StringTemplate view engine for ASP.NET MVC and other endeavors).  For the most part these templates are nothing special, they generate both the T-SQL (stored procedures) and a simple but effective data access layer.  Like I said nothing special.

A good resource for starting with T4 templates is @ David Hayden site where he has a Screencast on how to use them.  Below describes some of the settings used to get my simple sample up and running.
Extract the, and files from the zip and add them to your VS project in a folder (like Generation).  In the file there are some settings (variables) that you can use to modify how the code is generated.  You will need SQL 2005 client tools installed on your machine as it uses the SMO object library.  Once the code is compiled just cut and paste it into separate class files and run the T-SQL code on your db.

  • ConnectionString - This is your connection string to your database
  • TableName - This is the table you are going to run the code against
  • SchemaName - Use this for applying a schema to your T-SQL code if you use schemas (default is dbo)
  • ColumnsToOmit - Comma delimited list of columns to omit from the DAL code that is generated
  • NameSpace - Namespace of your application
  • ProcPrefix - Use to add a prefix to your stored procedures (ie. up_)
  • UseShortProperties - True | False to tell code generation to generate the C# short form for get/set properties
  • insertColumnsAsGetdate - Comma delimited list of column names that will automatically be assigned the GETDATE() T-SQL statement on an Insert.  (Also omits the fields from the insert statement parameters)
  • updateColumnsAsGetdate - Comma delimited list of column names that will automatically be assigned the GETDATE() T-SQL statement on an Update.  (Also omits the fields from the update statement parameters)

The code is supplied as is and if it's broken fix it, you're a programmer aren't you?  :P

T4 (4.98 kb)

Run As Administrator Shortcut

When developing using Visual Studio (VS) Microsoft recomends that you run VS with elevated permissions for debugging, for the most cases you really don’t need to do this but if you want to make it easier on yourself you can force VS to elevated permissions on the shortcut.  Just right click on the shortcut and select Properties from the context menu then select the Compatibility Tab and check off the Run As Administrator check box as seen below.  Now you probably want to turn off the UAC feature with this as well, this guide shows a few ways to do this.

That’s it.

When refactoring goes bad

So I ran into this little nugget this morning while working on a C# WinForms project in VS 2008 (might be an issue in VS 2005 as well).

Compiler Error: The item "*.resources" was specified more than once in the "Resources" parameter.  Duplicate items are not supported by the "Resources" parameter.

Seems that when I copied an existing form and renamed the copy to something else (using the properties window) the refractor tool decided that the source form name needed to be changed as well.  Apparently this is a common issue as I did a search for the problem online.  Normally when you do a rename in a code file you get the option to preview the changes and apply what you want to.  If you do this in the properties window or rename a class file in the solution explorer it seems to just make the change without a preview and globally.

I think that I need more control with this feature so you can turn this off in the IDE under Tools (for VS2008):

  • Options
    • Windows Forms Designer
      • General:
        • Set “EnableRefactoringOnRename” to false.

Doing this still allows you to do your refactoring (via the context menu) but now you have more control over what gets renamed.  And as an added bonus it's also a performace tweek to the IDE.