Compilation of nice add-ins for Visual Studio and TFS

June 20, 2011

Terje Sandstrøm has got a really nice compilation of tools and add-ins for Visuakl Studio and TFS.



New AppFabric WCF DataService Template

August 24, 2010


Ron Jacobs have created a new template for AppFabric WCF DataService. Check it out!

·         WCF Data Services enables the creation and consumption of OData services for the web (formerly known as ADO.NET Data Services).

·         Windows Server AppFabric provides tools for managing and monitoring your web services and workflows.

The AppFabric WCF DataService template brings these two products together providing the following features:

  • Monitor the queries to your service across multiple servers with AppFabric Monitoring
  • Properly report errors to Windows Server AppFabric (WCF Data Service errors are not recognized by AppFabric otherwise)
  • Eliminate the .svc extension from the URI by using routing
  • Provide a simple HTML page for invoking the service with or without the .svc extension

Get It

·         Download it from Visual Studio Gallery

·         Watch it on

If you have the guidance and the template along together in one package you simply add a new AppFabric WCF Data Service to your project and everything you need to know shows up right in Visual Studio – how cool is that?


Check out the Visual Studio Database guide

August 24, 2010

Visual Studio Database Guide has been published on Codeplex.

Project Description

Practical guidance for Visual Studio 2010 Database projects, which is focused on 5 topic areas:

·         Solution and Project Management

·         Source Code Control and Configuration Management

·         Integrating External Changes with the Project System

·         Build and Deployment Automation with Visual Studio Database Projects

·         Database Testing and Deployment Verification

This release includes common guidance, usage scenarios, hands on labs, and lessons learned from real world engagements and the community discussions.

The goal is to deliver examples that can support you in real world scenarios, instead of an in-depth tour of the product features.

Visual Studio ALM Rangers

This guidance is created by the Visual Studio ALM Rangers, who have the mission to provide out of band solutions for missing features or guidance. This content was created with support from Microsoft Product Group, Microsoft Consulting Services, Microsoft Most Valued Professionals (MVPs) and technical specialists from technology communities around the globe, giving you a real-world view from the field, where the technology has been tested and used.

For more information on the Rangers please visit and for more a list of other Rangers projects please see

What is in the package?

The content is packaged in 3 separate zip files to give you the choice of selective downloads, but the default download is the first of the listed packages:

·         Visual Studio Guidance for Database Projects –> Start here

·         Visual Studio Database Projects Hands-On-Labs document

·         Hands-On-Labs (HOLs), including:

o    Solution and Project Management

§  Refactoring a Visual Studio Database Solution to Leverage Shared Code

o    Source Code Control and Configuration Management

§  Single Team Branching Model

§  Multiple Team Branching Model

o    Integrating External Changes with the Project System

§  Maintaining Linked Servers in a Visual Studio Database Project

§  Complex data movement

o    Build and Deployment Automation

§  WiX-Integration with deployment of databases

§  The Integrate with Team Build Scenario

§  Building and deploying outside team build

o    Database Testing and Deployment Verification

§  The “Basic” Create Unit Test Scenario

§  The “Advanced” Create Unit Test Scenario

§  Find Model drifts Scenario


·         Contributors

o    Shishir Abhyanker (MSFT), Chris Burrows (MSFT), David V Corbin (MVP), Ryan Frazier (MSFT), Larry Guger (MVP), Barclay Hill (MSFT), Bob Leithiser (MSFT), Pablo Rincon (MSFT), Scott Sharpe (MSFT), Jens K. Süßmeyer (MSFT), LeRoy Tuttle (MSFT)

·         Reviewers

o    Christian Bitter (MSFT), Regis Gimenis (MSFT), Rob Jarrat (MSFT), Bijan Javidi (MSFT), Mathias Olausson (MVP), Willy-Peter Schaub (MSFT)


Bitwise checks on enums and the HasFlag method in .net 4

March 23, 2010

I was trying to create some code today to have several values of an enum selected at the same time. This is not too hard, you achieve this by using the FlagsAttribute in the .net framework.

The way you create it i like this:

public enum ElementNumberEnum
    One = 1,
    Two = 2,
    Three = 4

Many people use hex values for the enum, nut I see no reason not using decimals, it makes the code more readable.

As you see it goes 1, 2, 4. This is to be able to set the flags securely. What happens under the cover is that the value is set by adding the numbers(simple version, read here for more), so if all flags are set, the value is 7. If you know a bit about bits, and’s and or’s, you will know how it works. Let’s say you create it with 1, 2 and 3 as the values. If you then set The flag for One and Two, the value would be 1+2=3. However, 3 is now the value of Three. The result would be that our check will return that all values are set, when in fact only one and two should be.

Then you need to set multiple values to the enum. This is fairly simple as well. One way to do it is like this:

ElementNumberEnum number = new ElementNumberEnum();
number = ElementNumberEnum.One; //Setting
number |= ElementNumberEnum.Two; //Adding

Or like this:

ElementNumberEnum number = ElementNumberEnum.One | ElementNumberEnum.Two;

That only leaves one thing, actually checking for the value of things. And this is where things get a little bit more complicated. The check to see if the One flag was set used to be like this:

(ElementNumberEnum.One == (number & ElementNumberEnum.One))

This is not very readable, and in my case I had one more check to do, so it looked messy, I hate messy code. So this is where .net framework version 4 really saves my world. The framework is not released at the moment, but will be on April 12. It is currently available in the RC version.

In .net 4 they added a HasFlag(Enum enum) method to the enums. This make the previous call into this one:


And that makes the last part as simple as the 2 previous ones.

But remember, this does not change that you need to set the values on the enum to 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 etc. to be able to do proper checks on which flags are set.


So I decided I wanted to loop through the enum and do an action if the flag is set. Maybe not your everyday scenario, but it comes in handy in my case.

After some digging into my old Math knowledge, it actually turned out quite easy to accomplish.

First, just for readability i added a Max in Min value to the enum, so it looks like this:

public enum ElementNumberEnum
    Min = One,
    One = 1,
    Two = 2,
    Three = 4,
    Four = 8,
    Five = 16,
    Max = Five

Take a simple for loop and add some math, and you have this:

for (int i = (int)ElementNumberEnum.Min ; i <= (int)ElementNumberEnum.Max; i = i  * 2)
    if (number.HasFlag((ElementNumberEnum)i))
        Console.WriteLine("Enumm value: " + i + " Index : " + (int)(Math.Log(i) / Math.Log(2)));

Things to note here is the log functions to get the right index value. Remember that you have to add some check that the item exists in the collection.

And that solved at least my problem 🙂

Chaining constructors with inheritance

March 19, 2010
Technorati Tags:

So I was just wondering, what happens if I have chained constructors in a class that inherits from an abstract class that has chained constructors.

I have this abstract class:

public abstract class MyAbstract
    public MyAbstract(string name) : this()
        Console.WriteLine("MyAbstract name constructor executed!");

    public MyAbstract()
        Console.WriteLine("MyAbstract default constructor executed!");

And this class that inherits from the abstract class:

public class MyClass : MyAbstract
        public MyClass (string name) : base(name)
            Console.WriteLine("MyClass name constructor executed!");

        public MyClass() : base()
            Console.WriteLine("MyClass default constructor executed!");

So the big question is if I do a new MyClass(“Name”), what will happen?

What I want to happen is of course that all 4 constructors should run. But will the default constructor on the ever get called, or does it execute the called constructor for then going to the abstract class and execute the chained constructors there?

The answer is the latter. First the default constructor on the abstract is called, then the name constructor on the abstract, and then the name constructor in MyClass.

In my case I could easily get around it, because I was only setting a property. A default value on the property solves that. Like this:

public bool ReplyReceived { get; set; }

But if you want to execute methods in all the different constructors, I guess the best way is to create a private method in the MyClass. So I changed the MyClass to look like this:

public class MyClass : MyAbstract
    public MyClass (string name) : base(name)
        Console.WriteLine("Name constructor in MyClass executed!");

    public MyClass() : base()

    private static void MyClassInit()
        Console.WriteLine("Default constructor in MyClass executed!");

Here is a blog post from Eric Lippert explaining some things about why it is implemented like this.