Thursday, January 18, 2007

* .NET Tip #5 : How to use an Application Configuration File to target a .NET Framework Version

Suppose the application has been built against version (x).

The version of the framework which application runs on is determined by following steps :

1. If the version (x) is present, the application runs on that version.

2. If the version (x) is not present and config file does not specify the version in <supportedRuntime> element, the application runs on latest version that is present but not older than version (x).

3. If the version (x) is not present and config file specifies a version in <supportedRuntime> element, the application runs on latest version that is specified and present on the computer.

A sample config file entry :

<?xml version ="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v1.1.4322" />
  </startup>
</configuration>

If you dont want your application to run on the latest version incase the version (x) is not present, you can use element <requiredRuntime>.

Other Tips

Static Classes

.NET Namespace Alias

No comments:

Post a Comment