Wednesday, February 16, 2011

Fixing the Windows Identity Foundation 3.5 Templates

If you are still using Microsoft.Net Framework v. 3.5, but have since moved to Visual Studio 2010, unfortunately, you are out of luck in regards to the Windows Identity Foundation SDK.  The currently available version of the Windows Identity Foundation SDK 3.5 only supports Visual Studio 2008.  If you want the templates for Visual Studio 2010, you have to install Windows Identity Foundation SDK 4.0.

Well, if you still want to develop using Microsoft.Net Framework v. 3.5 and Windows Identity Foundation (for example, if you are a SharePoint 2010 developer), have no fear, there is still a workaround available.

As it turns out, the Visual Studio project templates used for Visual Studio 2008 do not differ greatly from the Visual Studio 2010 templates.  However, if you attempt to create a new Web Site project using the existing Visual Studio 2008 templates, you will get an error during the project creation.

Fortunately, the main difference between the Visual Studio 2008 and Visual Studio 2010 project templates comes down to a single file! (*.webproj)

After comparing the files used by Visual Studio 2010 and Visual Studio 2008, as it turns out, the *.webproj files simply need to be edited to support Visual Studio 2010.

You can simply manually edit these *.webproj files and add these lines:


C#
$targetframeworkversion$


After doing that and saving the project template, I was able to use the Windows Identity Foundation SDK 3.5 samples in Visual Studio 2010!

Here are the complete steps that I followed:


  1. Open Windows Explorer
  2. Navigate to Program Files\Windows Identity Foundation SDK\v3.5\Visual Studio Extensions\9.0
  3. From each of the .zip files extract the respective *.webproj files
  4. Add the text noted above to each of the *.webproj files
  5. Save the .webproj files
  6. Using a utility such as WinZip, WinRaR etc. replace the *.webproj files into their respective .zip files
  7. Save the changes to the .zip files
  8. Copy the modified .zip files to the location of the Project Templates (usually a location such as C:\Users\<user name>\Documents\Visual Studio 2010\Templates\ProjectTemplates\Visual C#)
  9. If you currently have any running instances of Visual Studio 2010, close them down.
  10. Re-launch Visual Studio
  11. Now, when you click on File-->New-->Web Site (with the .Net Framework 3.5 selected), you should see a set of Project Templates that will allow you to create Claims-aware Web Sites!
Update: You can now download .Net 3.5 compliant WIF Project Templates for Visual Studio 2010 from here: http://visualstudiogallery.msdn.microsoft.com/ccbc83fe-43f8-4187-b6c1-257488712a6b

1 comment:

  1. Thanks, this saved us a headache! We were faced with that HRESULT error and couldn't figure it out.

    ReplyDelete