Team Foundation Error: You are not logged into Windows Live Messenger

I recently started getting an error dialog popping up saying "Team Foundation Error: You are not logged into Windows Live Messenger" when opening VS.NET 2008 Team Explorer.

Apparently windows live can interface with TFS for collaboration purposes but if you're not interested in using that feature here is how to be rid of the annoying popup:

1. Open VS Team Explorer
2. Right-click on 'Team Members' and select 'Personal Settings'
3. Under 'Collaboration' click 'Change'
4. On the opened dialog select 'None' and click 'OK'

Convert from IEnumerable<gobject> to IEnumerable<x>

The easiest way to convert from IEnumerable<object> to a specific class e.g. IEnumerable<DomainObject> is by using the LINQ extension method Cast<T>.

IEnumerable<object> objEnum = GetData();
IEnumerable<DomainObject> domainObjEnum = objEnum.Cast<DomainObject>().ToList();


The same process can be used in reverse.

Free ASP.NET 4.0 hosting

The other day I was looking for some cheap asp.net hosting for a hobby project and came across http://www.aspspider.com/ which offers FREE hosting!

http://www.aspspider.com/ is a great place to learn or to throw up something quickly and the toolset is fantastic given the price.

Highly recommended.

Binding to a Settings file

Something that I find really cool is that you can bind directly to a user settings file in wpf. In the example below I've bound a toggle button to a user setting in a settings file. Toggling the button will update the settings file with 0 code!

<ToggleButton x:Name="btnNetworkSpeed" Margin="5,0,0,0" FlowDirection="LeftToRight" IsChecked="{Binding Source={x:Static InfrastructureProperties:Settings.Default}, Path=IsSlowConnectionSpeed, Mode=TwoWay}" FontSize="9"/>

The trick to making this work is to change the settings file access modifier to Public. To do this go into the settings file and at the top of the designer there is a drop down. What this does under the covers is change the compile tool from 'SettingsSingleFileGenerator' to 'PublicSettingsSingleFileGenerator'

If you want the setting to be persisted on the closing event of the application add this line and you're done.

protected override void OnExit(ExitEventArgs e)
{
Modules.Infrastructure.Properties.Settings.Default.Save();
...
}

Insert binary data like images into SQL Server

A fairly common problem is inserting data directly into binary data columns in SQL Server without a front-end application. The example below is the simplest solution I've seen and can be run straight from SQL Server Management Studio (SSMS).

In the below example I'm updating the an image column 'Icon' with an image file saved on the hard drive.

Update myTable
set Image = (
SELECT *
FROM OPENROWSET(BULK N'C:\image.png', SINGLE_BLOB) test)
where ImageID = 1