Search code examples
visual-studiosilverlight.net-framework-versionnew-project

For Silverlight projects, does it matter what .NET Framework version I choose in the "New Project" dialog?


As far as I know, Silverlight applications do not run on the .NET Framework's CLR, but on an independent, subset version of it called the Core CLR. I also know that I can change the Silverlight version in the Project Properties window:

Project Properties window with the "Target Silverlight Version" setting highlighted

Yet, when I create a Silverlight Application project via the New Project dialog, I can choose a .NET Framework version:

Visual Studio's New Project dialog with the ".NET Framework" setting highlighted

Does this choice of a .NET Framework version have any effect whatsoever for Silverlight projects, or is this setting ignored?


Solution

  • Short answer: The .NET Framework version option has no immediate effect on the Silverlight project created, but on the (optional) ASP.NET Web Application project that will host the Silverlight application.

    Longer answer:

    When creating a Silverlight Application project, Visual Studio will ask you whether you want to also create a ASP.NET Web Application project to host your Silverlight application:

    New Silverlight Application dialog with the "Host in a new Web site" setting highlighted

    If you choose to create such a project, it will target the .NET Framework version chosen in the preceding New Project dialog.

    To verify whether the .NET Framework version option really has no effect on the Silverlight project itself, I created two Silverlight Application projects, one with the .NET Framework 4 selected, and another project with .NET Framework version 4.5.1. Then I compared the two generated .csproj project files. Neither project file mentions any .NET Framework version at all, but instead this:

    <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>