Azure Web Role Project Template Depends on Target .NET Version

Visual Studio 2010 has this great ability to target multiple versions of the .NET Framework.  However, as invaluable as that feature is, it has caused me problems multiple times in the past couple of weeks.  Admittedly, the problems are really caused by me not paying attention, but it’s much easer to blame the tool than the developer!

Last time I had a problem with the multi-targeting ability of VS 2010 was when I couldn’t find the MEF assemblies.  This time, the problem was that I was getting a completely different project template for a Windows Azure Web Role than I expected.  I am working on content Windows Azure course, and all of a sudden my demo projects were coming up with a different project template for my Web Roles.  Turns out, it was the Target .NET Framework again. 

If you have Visual Studio 2010 targeting the .NET Framework when you create a Windows Azure Project as follows:

35Project

You can see that the role project templates are then also .NET Version specific…

35Roles

And then the project that get’s created for the .NET 3.5 Web Role, is a mostly empty ASP.NET Website….

35WebRoleSolutionExplorer

The same sequence for .NET Framework 4.0 however yields:

40Project

40Roles

40WebRoleSolutionExplorer

Some day, maybe I’ll learn my lesson and pay attention in the darn new project dialog. 

Finding the Elusive MEF Assembly (System.ComponentModel.Composition.dll)

I’m working on a sample project that needs to be able to process each file in a folder differently based on the type of file.  I wanted to build it using a plugin model, and decided this might finally be a reason to learn more about MEF.  I spun up a new project in Visual Studio 2010, but for the life of me couldn’t find the System.ComponentModel.Composition.dll that contains the MEF classes. 

Turns out the project I started was targeting the .NET Framework 3.5 runtime.  I changed it to the .NET 4.0 Framework, and voila, System.ComponentModel.Composition.dll now shows up in the Add References dialog. 

image

I feel like an idiot, but I spent probably 30-40 minutes looking for that sucker. 

FYI, its here (at least on my box):

C:\Program Files (x86)
   \Reference Assemblies
    \Microsoft
     \Framework
      \.NETFramework
       \v4.0
        \System.ComponentModel.Composition.dll

OR

C:\Program Files (x86)
   \Reference Assemblies
    \Microsoft
     \Framework
      \.NETFramework
       \v4.0
        \Profile
         \Client

          \System.ComponentModel.Composition.dll

FYI