zoukankan      html  css  js  c++  java
  • 私有程序集的探测过程

    一段伪代码描述私有程序集的探测过程,摘自: TOM BARNABY 著的  《.NET 分布式编程》

              function ProbeForAssembly( AsmName, AppBase, Culture, PrivatePath)

    // AsmName = The friendly name of the assembly, e.g., MathLibrary

    // AppBase = Path where the requesting application resides

    // Culture = The assembly reference culture, e.g., "En"

    // PrivatePath = The list of  search paths specified  in the app config  file

     

    // Search first for DLL extension  then EXE extension.

    for each Ext in {"dll", "exe"}

    Search( AppBase\AsmName.Ext )

     

    if Culture == "neutral" Then

    Search( AppBase\AsmName\AsmName.Ext )

    else

    Search( AppBase\Culture\AsmName.Ext )

    Search( AppBase\Culture\AsmName\AsmName.Ext )

    end if

     

    // Search in all the paths specified  in the app config  file

    for each Path in PrivatePath

    if Culture == "neutral" Then

    Search( AppBase\Path\AsmName.Ext )

    Search( AppBase\Path\AsmName\AsmName.Ext )

    else

    Search( AppBase\Path\Culture\AsmName.Ext )

    Search( AppBase\Path\Culture\AsmName\AsmName.Ext )

    end if

    next Path

    next Ext

    end function

     这里的AsmName指被引用的程序集的友好名,AppBase为当前应用程序所贮存的位置,

    Culture为AsmName的语言文化信息,PrivatePath为AsmName所在的位置。

    于C#中,可在AssemblyInfo.cs中,设置[assembly: AssemblyCulture("zh-CN")]来指定Culture信息,

    默认(不指定)为neutral。 在App.config中,通过配置来指定PrivatePath.

    privatePath
     

    整个probing的过程,伪代码已经描述的很清楚了,最好大家亲自验证下,以加深理解。我做了测试,整个

    probing过程分毫不离于伪代码的描述的。这里要补充的一点:<codeBase>元素,当存在该元素时,

    会跳至codeBase所指定的位置来加载指定名称的程序集的。

    需要说明的:存在codeBase时,则不会再按如上描述的probing过程进行探测的,会优先进行codeBase的搜索。

    且当程序集为非强名称的时候,codeBase指定的路径只能相对于当前路径的子目录(该情况下就无使用codeBase

    的必要了); 强名称时,可为本机或网络的任意地方的。

    CodeBase
  • 相关阅读:
    web.xml文件中元素的作用
    spring获取webapplicationcontext,applicationcontext几种方法详解
    web.xml文件中的Listener元素的作用
    IT旅途——程序员面试经验分享
    软件工程师的十个“不职业”行为
    雷军系好生意:小米,不是一家公司在战斗!
    tomcat 5.0 linux 配置
    ubuntu tomcat6.0 JAVA 变量
    初创企业的初创之路
    架构设计和包图
  • 原文地址:https://www.cnblogs.com/FallingAutumn/p/1252054.html
Copyright © 2011-2022 走看看