How Does .NET Locate an Assembly?


There are three separate procedures for locating an assembly:

  • Examining a configuration file

  • Probing

  • Using a Codebase

The application calls a referenced assembly containing information about the assembly, for example, Name, Version, Culture, and Public Key. First, it examines a configuration file. You can update your assembly by creating a configuration file that looks something like this:

<configuration>
<runtime>
<AssemblyBinding xmlns = "urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<AssemblyIdentity name="IFCE"
<publicKeyToken = "6cf7280fa2c8aa7"/>
<bindingRedirect oldVersion = "1.0.0.0" new version = "2.0.0.0"/>
</dependentAssembly>
<publisherPolicy apply="yes"/>
<probing privatePath="C:\Visual Studio Solutions\IFCE"/>
</assemblyBinding>
<gcCurrent enable="true">
</runtime>
</configuration>

Another tool, mscoref.msc, manages and configures the assembly. Its location is C:\Visual Solutions\Microsoft.Net\Framework\.

Note

You must have a client application before you can employ mscoref.msc.

Probing means the runtime looks for the assembly using the following search criteria: The runtime examines the GAC for the assembly’s strong name. If the assembly is private, the runtime searches the application root directory, called the APPBase. If it sees a reference for an assembly, it searches for your DLL. If the assembly is not an APPBase, the runtime alternately searches the configuration file for any specified path. It the assembly is not there, it searches the bin directory.

A <codeBase> element specifies where the CLR can locate your assembly. The runtime uses a configuration file only if the file contains a Redirect Assembly version. After the CLR determines the appropriate version to load, the runtime applies the codebase setting from the file specifying the assembly’s version. Here is an example:

<configuration>
<runtime>
<assemblyBinding = "urn:schemas-Microsoft-com:asm.v1">
<dependentAssembly name ="IFCE Process"
PublicKeyToken = "6cf7280fa2c28aa9"
Culture = "en-us"/>
<codeBase version="2.0.0.0"
href="http://www.dps.com/IFCEProcess.dll"/>
</dependentAssembly>
</assemblyBinding>
</.runtime>
<configuration>

Note

Codebase is available for use in an application configuration file, machine configuration file (for example, machine.config), and the publisher policy file.




.NET & J2EE Interoperability
Microsoft .NET and J2EE Interoperability Toolkit (Pro-Developer)
ISBN: 0735619220
EAN: 2147483647
Year: 2004
Pages: 101
Authors: Simon Guest

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net