.NET Framework Targeting Error (.NET Framework Client Profile)

May 25, 2010

Two of my colleagues: Alon Nativ and Ziv Farjun have found an interesting, yet confusing, issue in Visual Studio 2010 and .NET Framework 4.

They work on a .NET Framework 4 solution which includes few .NET Framework 4 projects. To test the project they created a Console Application project, added a reference to their other projects, used the appropriate namespace, and created a class that is defined in one of their projects. Everything is made by the (old) book. However, the project failed to build.

The error they got was: The type or namespace name "name" does not exist in the namespace "namespace". (Are you missing an assembly reference?)

The problem occurred because the new Console Application targeted the.NET Framework 4 Client Profile (which is the default for this project template) while the other projects targeted the full .NET Framework version 4.

.NET Framework Client Profile

The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications. It provides functionality for most client applications and it enables faster deployment and a smaller install package for applications that target the .NET Framework 4 Client Profile.

Applications that target the .NET Framework 4 Client Profile typically improve the deployment experience by having smaller download sizes and quicker install times. An application that targets the .NET Framework 4 Client Profile has a smaller redistribution package that installs the minimum set of client assemblies on the user’s computer, without requiring the full version of the .NET Framework 4 to be present.

The list of the reference assemblies included in the .NET Framework 4 Client Profile can be found here.

Several project templates in Visual Studio 2010 target the .NET Framework 4 Client Profile. The following is a list of some project templates in Visual Studio 2010 that target the .NET Framework 4 Client Profile by default:

  • 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

If you attempt to reference an assembly in your project that is not included in the .NET Framework Client Profile, Visual Studio will display an error message. That is what happened to my colleagues.

Common errors include the following:

  • The type or namespace name "name" does not exist in the namespace "namespace". (Are you missing an assembly reference?)

  • Type "typename" is not defined.

  • Could not resolve assembly "assembly". The assembly is not listed as part of the "profile" Profile.

These errors can result from different actions:

  • You have referenced an assembly that is not Included in the Client Profile

  • You have referenced a project or assembly that targets a different version of the .NET Framework

  • You have re-targeted a project to a different version of the .NET Framework

  • You have re-targeted a project to a different version of the .NET Framework and references do not resolve

We fixed it by setting the Console Application project to target the full .NET Framework version 4 instead of the .NET Framework 4 Client Profile subset library. Here is how you do it.
Other solutions for other .NET Framework targeting errors can be found here.

EAVB_YTINPBKIEU

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*