Codebase Probing

Assembly probing can be used only to locate assemblies in subdirectories relative to the location of the application. The .NET Framework provides another alternative to the GAC that can be used to locate assemblies anywhere on the local system as well as on remote Internet servers; this alternative is available through the codebase element of an application configuration file. The following example demonstrates how to look for version 1.0.0.0 of the StringPrinter assembly in the C: emp directory of the local system:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="StringPrinter"
                    publicKeyToken="539a6301c167d487"
                    culture="" />
                <codeBase version="1.0.0.0"
                    href="file://c:	empStringPrinter.dll"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

The details for specifying an assembly are the same as for a version policy file. This example specifies a local directory, but the href attribute can also be used to specify any valid URL. This can be used to locate assemblies on remote servers; for example, the URL http://www.mycompany.com/StringPrinter.dll would cause the assembly to be downloaded using HTTP.

Caution

The codebase attribute is subject to version policy files installed in the GAC. For example, if there is a policy that redirects version 1.0.0.0 to version 2.0.0.0, the technique shown in our example won’t be able to locate the desired assembly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset