共用方式為


What’s new in .NET Framework 4 Client Profile Beta 2

Introduction

Hopefully folks have seen Soma’s blog announcing the availability of Beta 2 of Visual Studio 2010 and .NET Framework 4.
In .NET Framework 4 we have introduced a streamlined subset and more compact version of the .NET Framework called the Microsoft .NET Framework 4 Client Profile (aka NET4 Client Profile).
The Microsoft .NET Framework 4 which is the Full Framework(aka NET4 Full) still exists and it is a superset of the Client Profile.

The Client Profile is smaller in size and its goal is to improve the deployment size, time, reliability and overall deployment experience for client applications.

The Client Profile contains the functionality that most common desktop client applications (including Windows Forms and WPF applications) would need, so we expect that many client application developers will target it. This will improve the overall application deployment experience when the application requires .NET Framework 4 to be installed.

One of the most important improvement over NET 3.5 SP1 Client Profile, is NET4 Client Profile is now supporting all platforms and OS's that are supported by the Full Framework including Vista, XP, Win2k3, Win2k8, Windows7, x86/x64 (excluding IA64).

Few desktop applications may still need to target the NET4 Full if they must use features that are not included in the NET4 Client Profile.

My previous blog discussed Beta1, in this blog I will focus on Beta 2.

What are the reasons for a Client Profile?

Keeping the Client Profile small provides:

  • Improve the deployment time of the Framework and the overall deployment time of applications that chain the Framework.
  • Reduce the Framework deployment failures
  • Reduce the redist space that is needed on ISV’s media and allow more space to ISVs applications
  • By keeping ASP.Net and other components (that are mostly needed for servers) out of the Client Profile, the attack surface and the number of future servicing events which may be caused by ASP.Net are reduced.

How big is the Client Profile?

Below are the redistributable download size improvements since NET 3.5 SP1.
This shows that on x86, with NET4 Client Profile you can save up to 86% of the Framework deployment size compare to 3.5 SP1 Full.

Note that if you are downloading from the Web, the actual download size could be smaller since some components may already be on your machines (for example, Windows Imaging Components, Software Rasterizer (rgb9rast) , etc )

 

3.5 SP1

4.0 Beta1

4.0 Beta2

32 bit Client Profile

Online: ~28 MB**

Offline: 255 MB

34.2 MB

30.9 MB

32 + 64 bit Client Profile

N/A

71.3 MB

47.1 MB

32 bit Full

N/A

76.5 MB

37.7 MB

32 + 64 bit Full

N/A

157 MB

54.5 MB

32 + ia64 bit Full

N/A

161.6 MB

56.4 MB

32 + 64 + ia64 bit Full

231 MB

N/A

N/A

** NET 3.5 SP1 Client Profile web download install ~28mb on XP machines that have no framework, it otherwise installs the  NET 3.5 SP1 Full. See more here.

When to use NET4 Client Profile and when to use NET4 Full Framework?

Client Profile:
We recommend that the NET4 Client Profile be utilized as the primary framework for most client desktop applications (including Windows Forms and WPF apps).
Since we are considering to make the NET4 Client Profile available broadly to desktops via Windows Update, most client desktops may have NET4 Client Profile soon after NET4 releases making it ubiquitous*.
Until that time, NET4 apps can chain-install the NET4 Client Profile which is smaller and faster to install.

*Note: This plan is not final.

Full framework:
The Full framework is a superset of the Client Profile. It should mainly be used for:

    • Server apps (e.g. ASP.Net apps)
    • For developer scenarios (for example, this includes msbuild)
    • For all other legacy client scenarios (for example, this includes System.Data.OracleClient.dll which is being deprecated in NET4) that are not included in the Client Profile.

What is new in NET4 Client Profile Beta2 vs. Beta 1?

In Beta2 we made some significant changes to the NET4 Client Profile. The main changes include:

  • Client Profile now included additional functionality such as Speech and WF 4.0. (see list below)
  • To improve NETFX4 install time on 64-bit OS, we postpone NGEN (native image generation) of most 64-bit assemblies (except mscorlib.dll and system.dll) to when the machine is idle. (Typically this corresponds to ~5min of user inactivity).
    The reasons we made this change:
    1. Many new machines now have a 64-bit OS and this number is trending up very quickly. All these machines will benefit from faster NET4 deployment time.
    2. Most client apps on 64-bit OS will still be 32-bit apps running on WOW64, which will not be impacted by this change.
    3. Developers / IT Admins can always force NGEN of all .NET Framework assemblies by calling : "ngen executeQueuedItems 3", or separately NGEN each assembly they need.
    4. By the time we see a significant number of 64-bit apps, NET4 likely to already be ubiquitous and already NGEN’ed.
    5. Visual Studio 2010 has changed the compile default from “AnyCPU” to “x86”. Most developers will not change this, since very few NetFX4 apps have any reason to do so (more in this blog here).
  • Even though we have added a number of components to the Client Profile, with better compression we managed to still keep the Client Profile redist size low (e.g.: Beta 2 x86 is 30.9MB).
  • We removed the XPS Viewer and MSXML 6.0 from the Client Profile redist.
  • Visual Studio 2010 now automatically adds <app.config> (Application Configuration File) to NET4 Full Framework projects an entry to indicate to the CLR that the app requires the Full Framework.
  • By default, if <app.config> is missing from a NET4 app’s directory, CLR assumes that the application is targeting the Client Profile. This prevents apps that require the Full Framework from loading when run on NET4 Client Profile.
  • Note that NET4 Beta1 did not have this features and the default for NET 3.5 SP1 was Full.
  • In addition to redist deployment, we also added support for web download which did not exist in Beta 1. Your app can now chain-install NET4 (Client Profile or Full) from the Microsoft download site.
  • Much improved NGEN speed on multi-core machines by compiling on each core/processor concurrently. See more here. (Note: this also existed in Beta1)

What is new in Visual Studio 2010 for NET4 Client Profile

  • We changed many of the Visual Studio 2010 project templates to target NET4 Client Profile by default. See below.
  • The Visual Studio 2010 Prerequisites dialog (e.g. when you click ‘Publish’ in the property page in Windows projects) automatically selects the correct profile (Client Profile or Full) depending on your project target.
  • The Visual Studio 2010 “Setup and Deployment” project selects the NET4 Client Profile prerequisite by default.
  • We are considering making the NET4 Client Profile the Framework that will be distributed on Windows Update to desktops, thus making the Client Profile ubiquitous (Note: this plan is not final and could change)

How to use Client Profile in Visual Studio 2010

Visual Studio 2008 introduced multi-targeting for application projects to target 2.0 and 3.x versions of the .NET Framework.
Visual Studio 2010 has improved multi-targeting in order to allow developers to easily target the new NET4 Client Profile. As a matter of fact, starting in Beta2 many of the client projects are targeting the NET4 Client Profile by default.

Projects that target NET4 Client Profile by default

These projects are now target the NET4 Client Profile by default:

Windows Project (C# and VB) - WPF Application
- WPF Browser Application
- WPF Custom Control Library
- WPF User Control Library
- Windows Forms Application
- Windows Forms Control Library
- Console Application
- Empty Project
- Window Service

Visual F#
- F# Application
- F# Tutorial

Workflow (C# & VB)
- Activity Designer Library
- Activity Library
- Workflow Console Application

WCF (C# & VB) - WCF  Service Library

Office 2007 & 2010 templates (C# & VB) - All Projects

All other projects, including Class Library, target the Full Framework by default.
Mixed-target scenarios using Class Library may provide build errors, read more here.

How to retarget your project

To change targeting of your project, open the project properties, select the "Application" page, and change the “Target framework” drop-down.

C# project example:

image

VB project example (Project Properties > Compile tab > “Advanced Compile Options…”):

image

Note that if you right-click the project and select “Add References…”, the dialog shows only the .NET Framework assemblies that are part of the selected profile. This is accomplished by using reference assemblies (metadata-only versions of assemblies). The .NET Framework 4 Client Profile Reference Assemblies are located in:
  %programfiles%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client

At compile time, the reference assemblies are matched up against the known "Client List" assemblies that are included in the Client Profile. If a project targeting the Client Profile has a reference to a .NET assembly that is not included in the "Client List", Visual Studio displays compile-time errors in the Error List.

How to change targeting for other projects

Some other VS 2010 projects such as Managed C++ (Visual C++/CLR) still target the Full Framework by default. VS 2010 unfortunately does not provide UI to change the targeting.

Fortunately, you can still edit the project file manually in order to change the profile targeting. To do so:

  1. Right click “Unload Project”
  2. Right-Click “Edit <project_name>”
  3. Set the appropriate project property to target Client Profile. e.g.
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
  4. Right click “Reload Project”

In addition, for these projects, notice that VS does not create an <app.config> file for your project.
If your project does not add references or access assemblies that are included in the Full Framework but are not part of the Client Profile, there is nothing to worry about. Your app will run on machines with either NET4 Client Profile or Full Framework just fine.
Otherwise, if you do access assemblies from the Full Framework, you should add <app.config> to indicate to CLR not to load your app if it is launched on the NET4 Client Profile. E.g. add this

<?xml version="1.0"?>
<configuration>
    <startup>
              <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

If you don’t do so, your app may crash at random when it needs to load the assemblies that are missing from the Client Profile.

Deployment

The project Publish property page allows you to select the prerequisite needed for your ClickOnce deployment. In Beta2, VS2010 automatically selects the correct profile (Client Profile or Full) depending on your primary project target.

image

Setup and Deployment Projects

The same prerequisite dialog from above appears when you create “Setup and Deployment” (under “Add New Project”/“Other Project Types”). The NET4 Client Profile prerequisite entry is checked by default in this case.

image

image

If you create a new “Visual Studio Installer” setup project (under “Setup and Deployment“) and add the output of your NET4 Client Profile to it (do: Right-Click ->“Add”-> “Project Output…”’ select “Primary output”) , VS2010 adds a new “Launch Condition”. (Right-click on your new Setup project and then do “View->Launch Conditions”)
By default VS2010 will add NET4 Client Profile as a launch condition.
Note that a Beta2 bug still shows the Full Framework as the default launch condition; you can and should use the drop-down box to change it.
What this means is that once all prerequisites are installed and before the main installation launches, setup checks whether all the launch conditions are met. If not, setup blocks and displays an error message.

image

image

Important notes:

  • When you create new projects in VS2010, the “New Project” dialog does not indicate if the new project you are about to create is targeting Client Profile or Full. It is always a good idea to go to the project Properties above and confirm that you have the target framework you expected.

  • If you change the project to target the Full Framework, VS will add a configuration file (<app.config>) that declares the application as a "Full" application.
    image 
    This enables the CLR loader to block any NET4 apps that target “Full on machines that only have the Client Profile. In this case, the CLR prompts the user to install NET4 full. For example, you may see this dialog:

    Note that in NET4 Beta1 and NET3.5 SP1 Client Profile if the <app.config> was missing the CLR the assumption was that you targeted the Full Framework. This is now reversed.

  • You may encounter mixed-target scenarios: for example, when your Client Profile app adds a reference to a Class Library that is targeting the Full Framework (which it targets by default). You should be able to successfully build such solutions, as long as the Class Library does not use references to assemblies that only exist in the Full Framework. If it does, you may get warning/errors that are not completely clear.
    For example you may see an error in your Client Profile app saying:
    ”The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)”

    This error is not clear because the class library exists and can be compiled when it is compiled by itself. However, when MSBuild tries to resolve the transitive closure of the Client Profile project, it cannot find the Full Framework assembly that is referenced by the Class Library. In this case it is better to look at the generated warnings which are more informative:
    ”The referenced assembly "ClassLibrary1.dll" could not be resolved because it has a dependency on "…<some assembly only available in Full Framework>…” which is not in the currently targeted

  • In general, it is always good practice to check the targeting of all projects in your solution to make sure they are what you intended. Remember that Client Profile apps will always run on Full Framework, but not the other way around.

What components are new in NET4 Client Profile Beta2?

In order to enable most (if not all) client apps to only require the NET4 Client Profile, in Beta2 we added some additional functionality. The main components/features that were included in the Full Framework in Beta1 and moved to the NET4 Client Profile Beta2 are:

    1. Speech
    2. Network and other performance counters
    3. Workflow 4.0 features
    4. Directory services components
    5. WMI Instrumentations components
    6. VB6 compatibility components
    7. Visual Basic Compiler
    8. Spell Checker and Hyphenation functionality required for WPF RichTextBox
    9. Created a new System.Web.ApplicationServices.dll assembly and moved certain types from System.Web.dll into it
    10. New WPF 4.0 Text stack to improve text clarity (new to NET4 in Beta2)
    11. Location APIs for Windows 7

In general, other than ASP.Net, tools (like MSbuild, Web admin tools) and legacy components that are becoming deprecated (e.g. Workflow 3.0, Oracle data client) almost everything else is now included in Client Profile in Beta2.

Enhancements in NET4 Client Profile vs. NET 3.5 SP1 Client Profile

Although the concept of a Client Profile is not new and was introduced in .NET Framework 3.5 SP1, the NET4 Client Profile contains important improvements:

 

.NET Framework 4 Client Profile

.NET Framework 3.5 SP1 Client Profile

Supported OS

Supported on all platforms and  OS's that are supported by the .NET Framework (excluding IA64 and the Server Core role in W2K8)

Supported only on Windows XP 32-bit machines that did not have any .NET Framework version installed.

(Client Profile setup silently installs the full 3.5 SP1 Framework otherwise)

Redistributable

Supports redistributable as well as web download

Supports web download only

Add Remove Programs entries

The full Framework comprises the Client Profile and another part called “Extended”. Thus it has two entries in the  Add/Remove Programs dialog (or Programs and Features window).

To remove (or repair) the Full Framework you must remove the Extended part first, then the Client part.

If you installed the Full Framework, you can switch to the Client Profile by simply removing “Extended” from Add/Remove Programs.

Single entry in Add Remove Programs

Visual Studio

Improved support for Client Profile targeting in Visual Studio 2010.

By default many Visual Studio 2010 Beta2 Client project target the NET4 Client Profile.

Single checkbox in Visual Studio 2008 Service Pack 1 “Application” Project properties for .NET Framework 3.5 projects. Client Profile support unavailable in out-of-the-box VS 2008.

Features

Includes new .NET 4  features (such as Managed Extensibility Framework (MEF), C# 4 Dynamic Keyword, etc) as well as features previously included in NET 3.5 SP1 Full (Speech, WPF Spell Check, etc)

Subset of features in .NET 3.5 SP1 Full

 

What’s in and what’s not included in the Client Profile?

Features

Full Framework

Client Profile

Common Language Runtime

   

Can be installed side-by-side with older versions of the Framework

In-process side by side support

Improved COM interop

     

Innovations in the Visual Basic and C# languages

   

statement lambdas

implicit line continuations

dynamic dispatch

named/optional parameters

     

Base Class Library Improvements

   

Managed Extensibility Framework

Additional core data structures

I/O Improvements

     

Parallel Computing Innovations

   

Task Parallel Library (TPL)

Parallel LINQ (PLINQ)

     

ADO.NET

   

REST-based exposure of relational data

Entity Framework, LINQ to Entities

SqlClient, OLEDB, ODBC Managed Providers

XML, LINQ to XML

OracleClient

x

LINQ to SQL

Runtime design libraries for Entity Framework and ADO.NET Data Services

x

     

ASP.NET Innovations

x

     

ASP.NET AJAX Improvements

x

     

XAML Parser

   

Faster

More extensibility during XamlReader.Load and XamlWriter.Save

Ability to use generics               

Better References by Name

     

Windows Presentation Foundation

   

New line-of-business controls including charting control, smart edit, data grid, and others that improve the experience for developers who build data centric applications

Support in for Windows 7 multi-touch, ribbon controls, and taskbar extensibility features

Added support in WPF for Surface 2.0 SDK

     

Windows Communications Foundation

   

WCF Client Component

Service discovery

Router service

Simplified configuration

Improved queuing

REST support

Improved performance

WCF Client Component

     

Windows Workflow Foundation

   

Improved activity programming model

Improved designer experience

New flowchart modeling style

Expanded activity palette

Workflow-rules integration

x

New message correlation features

Significant performance gains for WF-based workflows

WF3 and WF3.5 in .NET 4

    x

 

 

 

Miscellaneous

 

 

Speech support

Various perf counters

MSBuild support

x

Visual Basic compiler and other compilers

•   Full Support
 Partial Support
X no support

Where can I get the NET4 Client Profile?

You can get .NET Framework 4 by click on “Download the Beta” from this site: https://msdn.microsoft.com/en-us/vstudio/dd582936.aspx

Redist vs. Web Download:

Web Download: For online scenarios, your application setup can chain-install the NET4 Framework from the Microsoft Download Center (or direct install by navigating to the download page).

When you use a web download, the .NET web bootstrapper is launched. The bootstrapper can determine your CPU architecture, locale, and components already existing on the machine, and can install only the components that are required. This is also known as ‘homesite’ deployment.

The .NET web bootstrapper also chain-installs the correct .NET Framework 4 Language Pack if your machine has a non-English locale.

Redist: For offline scenarios, you can also re-distribute (“redist”) the NET4 Framework on your own media (e.g. DVD) also known as ‘samesite’ deployment.

Install Flavors:

You can install the following flavors of the .Net Framework:

(The listed sizes are the package size, the space required on disk will be larger)

  1. dotNetFx40_Client_x86.exe (~30.91 MB): This is the Client Profile SKU that you could use to install on any supported 32-bit OS. You should redist on your own media. Choose this only if all your users are running 32 bit OS.
  2. dotNetFx40_Client_x86_x64.exe (~47.16 MB): This is the Client Profile SKU that you must install on any supported 64-bit OS. This will also install on any supported 32-bit OS. Your app could run in WOW64 if it was compiled w/ "32-bit" flag or as 64-bit if you compile with "AnyCPU" or "64-bit" flags.
    If you are redistributing the Framework with your application you most likely want to redist this package as it will be install on both 32 and 64 bit OS’s.
  3. dotNetFx40_Full_x86.exe (~37.71 mb): This is the Full Framework SKU that you could use to install on any supported 32-bit OS.
  4. dotNetFx40_Full_x86_x64.exe (~54.59 MB): This is the Full Framework SKU that you must install on any supported 64-bit OS. This will also install on any supported 32-bit OS.
  5. dotNetFx40_Full_x86_ia64.exe (~56.4 MB): This is the Full Framework SKU that you must install on IA64 OS. Client profile is not supported for IA64.
    (Even though technically you can remove “NET 4 Extended” in “Add/Remove Programs” and remain with Client Profile, it is not recommended that you do so. WPF is not even installed on IA64)
  6. NET 4 Beta 2 Web Bootstrapper: This is what you want to install if you need NET4 Full and you are online.
  7. NET 4 Client Profile Beta 2 Web Bootstrapper: This is what you want to install if you need NET4 Client Profile and you are online.

Note that above sizes are for ‘redist’ packages. With the Web installer the download size will likely be smaller since some of the components that are needed for NET4 may be already on your machine (e.g. rgb9rast.msi).

Feedback:

Please provide us with feedback. We really would love to know:

  • Does the NET4 Client Profile currently contain the right features set?
  • What functionality should be removed from or added to the NET4 Client Profile?
  • How easy it is to use in Visual Studio 2010?
  • Any other feedback?

Notes and caveats

  • Redistributable package size for the Client Profile is not final. Expect to see a smaller size by RTM.
  • Note that each setup package file name includes the word “Client” or “Full” to differentiate between the two packages. (e.g. dotNetFx40_Client_x86.exe, dotNetFx40_Full_x86.exe)
  • Setup may require a reboot, depending on the OS and currently running programs during installation.
  • We are still tweaking what should be in Client Profile vs. Full Framework, so there may be changes by RTM.
  • Support for the Client Profile Configuration Designer is not available in Beta 2 and likely will not be available before RTM.

Comments

  • Anonymous
    April 25, 2010
    Hi, When do you update Client Profile Configuration Designer for .NET Framework 4.0 Client Profile? Thanks. Martin