Visual Studio 2010 / SP1 / Windows SDK Install Order

When you plan to install the Windows 7/2008 R2 SDK, the SDK needs to be installed before VS2010 SP1.  Here is the recommended install order:

1. Visual Studio 2010
2. Windows SDK 7.1
3. Visual Studio 2010 SP1
4. Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1

Here is the link to the blog post about this:

Unit Testing Private Static Methods in C#

I had never needed to unit test a private static class method in C# before, but it turns out that Microsoft created a special object type to handle just such a case.

To test the private static method DetermineFilename (that takes filePath as a string parameter and returns a string) in the FileManager class, do the following:

PrivateType privateFileManagerObject = new PrivateType(typeof(FileManager));
string filename = (string)privateFileManagerObject.InvokeStatic("DetermineFilename", filePath);

Thanks to Venkat for posting this solution on his web site here:

Get SQL Server Version/Edition Information

Just connect to the database in which you are interested, open a new query window, and enter the following query:

SELECT SERVERPROPERTY('ProductVersion') as 'Product Version',
SERVERPROPERTY('ProductLevel') as 'Product Level',
SERVERPROPERTY('Edition') as 'Edition'

For me, this produced the following:

Product Version  Product Level  Edition
10.50.1600.1     RTM            Enterprise Edition (64-bit)

Disable C# “var” Recommendation in ReSharper

I have been trying to use type names instead of “var” in my C# code lately.  However, ReSharper wants me to convert every type name in a declaration to “var”.  The squiggles under my type names were driving me nuts, so I decided to dig into the settings to turn this off.

To disable these suggestions, do the following:

  1. Go to the ReSharper menu and select Options.
  2. From the resulting dialog box, select Code Inspection, Inspection Severity.
  3. Select the C# tab and then Language Usage Opportunities.
  4. Set both “Use var keyword when initializer explicitly declares type” and “Use “var” keyword when possible” to “Do not show”.


Where to Store Your PowerShell Profiles

I recently decided to get on the PowerShell bandwagon again (after starting many times and then forgetting “everything”), so I went to Scott Hanselman’s blog about using the Visual Studio environment from the PowerShell prompt. I followed everything in his article except where I was supposed to store my profile (i.e. startup script) for PowerShell.  It turns out that there are four places where you can put your profile, depending on whether it’s per-user or machine-wide.  They are as follows:

  • %windir%\system32\WindowsPowerShell\v1.0\profile.ps1

This profile applies to all users and all shells.

  • %windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1

This profile applies to all users, but only to the Microsoft.PowerShell shell.

  • %UserProfile%\My Documents\WindowsPowerShell\profile.ps1

This profile applies only to the current user, but affects all shells.

  • %UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

This profile applies only to the current user and the Microsoft.PowerShell shell.

I found this information on the following MSDN page.  I’m still learning about what the “Microsoft.PowerShell shell” is, but that’s where Scott recommended putting it.

So, here are the lines I added to the end of Scott’s VsVars32 function:

# add a call to set-consoleicon as seen!
. 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Set-ConsoleIcon.ps1'
Set-ConsoleIcon 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\vspowershell.ico'

Also, for those of your writing PowerShell scripts, note that the ‘#’ character is used at the beginning of a line to indicate a comment.

Finally, if you modify your profile and want to reload it, you can just issue the following command from the PowerShell prompt:

. $profile

Load more