Tuesday, October 16, 2012

Enable the full .NET Framework in Console Application

Console Projects created by Visual Studio 2010 support only a limited subset of the .NET Framework (read more about this on MSDN). This means that for such projects some libraries will be filtered away by VS2010 from the Add a Reference dialog.
To gain access to all .NET libraries available on your PC, you may want to tweak the element called TargetFrameworkProfile in the project file (=<your-project-name>.csproj). Follow the steps below:
  1. Open that file in a code editor of your choice (for example, in Notepad++),
  2. Find the TargetFrameworkProfile element. Notice that it is set to Client like below:
  3. Change it to <TargetFrameworkProfile  />.
  4. Then restart the project and enjoy the full version of the .NET Framework!
Note: As of .NET 4.5, the TargetFrameworkProfile property is discontinued (for more details see here).

Friday, October 5, 2012

Enable JSON serialization in your Visual Studio 2010 project

As far as I know, the project templates shipped with Visual Studio 2010 do not support JSON serialization out of the box. An additional library should be referenced by the project in order for the JSON serialization to be enabled. To add it, right-click on the References section, select Add Reference, go to the .NET tab and proceed to System.Runtime.Serialization:

Now you are ready to import the System.Runtime.Serialization.Json namespace to your source code!