Showing posts from 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:
Open that file in a code editor of your choice (for example, in Notepad++),Find the TargetFrameworkProfile element. Notice that it is set to Client like below:
<TargetFrameworkProfile>Client</TargetFrameworkProfile>.Change it to <TargetFrameworkProfile  />.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).

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!

Unhide a table row – a cross browser solution

When you need to hide an element on a web page, you would probably make use of the display: none style. But what if you have a table row hidden with display: none and you need to unhide it? Probably you would change its display property to table-row.
Regrettably, this solution may break down a table in IE7 or IE8. IE will show a table row in a proper manner with display: inline-block only. To make the layout compatible across multiple browsers, you may either opt for conditional comments or rely on style overriding:

Conditional Comments Create two sets of styles – one tuned for IE and another for the rest of browsers, and load them according to the user agent, like below: <!--[if IE]> <style type="text/css">.ticker-row { display: inline-block; } </style> <![endif]--><!--[if !IE]> --> <style type="text/css">.ticker-row { display: table-row; } </style> <![endif]--> The style declared first works in IE, whereas the s…