. NET specifies where the runtime looks for assemblies

Source: Internet
Author: User

There are two ways to specify the location of an assembly:

    • Use the <codeBase> element.

    • Use the <probing> element.

You can also use the . NET Framework Configuration Tool (Mscorcfg.msc) to specify an assembly location or for the common language runtime to specify the location to probe the assembly.

Using <codeBase> elements

The <codeBase> element is available only in the Computer configuration file or in the publisher policy file that also redirects the assembly version. When the runtime determines which assembly version to use, it applies the base code settings in the determined version of the file. If the codebase is not pointed out, the runtime probes the assembly in the usual way. For more information, see How the Runtime Locates Assemblies.

The following example shows how to specify the location of an assembly.

<Configuration>   <Runtime>      <assemblybindingxmlns= "Urn:schemas-microsoft-com:asm.v1">       <dependentassembly>         <assemblyidentityname= "MyAssembly"PublicKeyToken= "32AB4BA45E0A69A1"Culture= "en -us" />         <CodeBaseversion= "2.0.0.0"href= "Http://www.litwareinc.com/myAssembly.dll"/>       </dependentassembly>      </assemblybinding>   </Runtime></Configuration>

The version property is required for all assemblies that have strong names, but should be omitted for assemblies that do not have strong names. The <codeBase> element requires an href attribute. The version range cannot be specified in the <codeBase> element.

Attention

If you provide a basic code hint for an assembly that does not have a strong name, the hint must point to either the application base or a subdirectory of the application base directory.

Using <probing> elements

The runtime uses probing methods to find assemblies that do not have codebase. For more information about probing, see how the Runtime Locates Assemblies.

You can use the <probing> element in your application configuration file to specify subdirectories that the runtime should search for when looking for an assembly. The following example shows how to specify the directory that the runtime should search for.

<Configuration>   <Runtime>      <assemblybindingxmlns= "Urn:schemas-microsoft-com:asm.v1">         <probingPrivatePath= "Bin;bin2\subbin;bin3"/>      </assemblybinding>   </Runtime></Configuration>

The PrivatePath property contains the directory where the runtime should search for assemblies. If the application is in C:\Program Files\MyApp, then the runtime will be C:\Program Files\myapp\bin, C:\Program files\myapp\bin2\subbin, and C:\Program Finds an assembly in files\myapp\bin3 that does not have a base code specified. The directory specified in PrivatePath must be a subdirectory of the application base directory.

. NET specifies where the runtime looks for assemblies

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.