| I l @ ve RuBoard |
Side-By-Side Assemblies
To
After these steps are complete, two versions of the SharedComponent.dll should be visible in the GAC, as shown in Figure 5.2.4. Figure 5.2.4. Side-by-side versioning of SharedComponent.dll .
Rerun the client application and notice that the returned message is still
"Hello from version 1.0."
. It is important
NOT
to recompile the client application because the reference will now be to the
|
| I l @ ve RuBoard |
| I l @ ve RuBoard |
Custom Binding: Application Configuration
To allow the client application to make use of the newly built assembly, an application configuration file must exist in the same directory as the
.exe
. The configuration file will have the same name as the application
Listing 5.2.4 SharedClient.exe.config1: <?xml version="1.0"?> 2: <configuration> 3: <runtime> 4: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 5: <dependentAssembly> 6: <assemblyIdentity name="SharedComponent" 7: publicKeyToken="9ab72e2bd01f38e8" /> 8: <bindingRedirect oldVersion="1.0.547.38856" 9: newVersion="1.1.547.38908" /> 10: </dependentAssembly> 11: </assemblyBinding> 12: </runtime> 13: </configuration>
In the
assemblyBinding
section, all dependent assemblies are listed for rebinding. Each assembly to be redirected will have an entry. The entries consist of the
dependentAssembly
section that details the identity of the assembly and the binding information. The
config
file is a simple XML file used by the runtime to alter the environment for any application. Create a text file named
SharedClient.exe.config
and copy Listing 5.2.4; be sure to verify the version
With the configuration file in place, launch the SharedClient.exe application and notice that the text displayed in the label now says "Hello from version 1.1" (see Figure 5.2.5). This is due to the runtime rebinding the assemblies. Figure 5.2.5. SharedClient.exe with binding redirect.
Rather than creating the configuration file by hand, the .NET framework ships with a MMC snap-in that allows you to configure applications, including the assembly rebinding. In fact, I used the MMC snap-in .NET Admin Tool (
Figure 5.2.6. .NET Admin tool.
Microsoft's .NET Admin tool allows for editing of the
GAC
, configured assemblies, remote services, runtime security policies, and assembly binding. The tool itself is
Figure 5.2.7.
SharedClient.exe
in the Applications
|
| I l @ ve RuBoard |