Configuration Files
- This example assumes
that you have worked on the AssemblyVersioning
example.
- In this example we
will see how we can modify the version of assembly that we use, without
modifying the code or recompiling.
- Click on the start
button, settings, control panel. Double click on Administrative tools.
Double click on Microsoft .NET Framework Configuration.
- Click on Manage
Individual Applications.
- Click on Add an
Application to Configure.
- Either select the application from the list, or click on Other
and navigate to the User.exe from AssemblyVersioning.
- Make sure in the tree
view on the left, under Applications, User.exe is selected.
- Click on the View the
Assembly Dependencies.
- The list of assemblies
that this application depends on is shown.
- Now, in the tree view
on the left, select Configured Assemblies:

- Click on Configure an
Assembly.
- In the resulting
dialog, choose the appropriate option as shown below:

- Click on Choose
Assembly… button.
- Select the ASampleClass, and click on Select. Click on Finish.
- In the ASampleClass Properites
dialog, click on Binding Policy tab.
- Now view the assembly
directory (C:\Winnt\assembly) using Windows Explorer.
- Right click on the ASampleClass assembly, the older version and click on
properties.
- In this dialog, highlight
the version number (some thing like 1.0.859.31296) and click right mouse
button and copy to clipboard.
- Back in the ASampleClass Properties in the .NET Configuration
tool, paste that version number in Requested Version.
- Similarly, pick the
version number of newer ASampleClass assembly
and paste it into the New Version.
- Click on Apply and OK.
- Double click on the
User.exe in Windows Explorer and see what the output is.
- Now go back to the dialog
that allows you to set the version numbers and swap the version numbers
and see what the output is.
- Finally, lets find the configuration file that was updated by
this process.
- Go to the bin\Debug
directory where the User.exe is located. Notice there is a new file named User.exe.config that has been created. Open that file
in notepad and view.
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding
xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity
name="ASampleClass"
publicKeyToken="17645102c31e109c" />
<bindingRedirect
oldVersion="1.0.859.31240"
newVersion="1.0.859.31296" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>