转载:程序集的查找顺序
2016-06-06 21:23
302 查看
https://msdn.microsoft.com/zh-cn/library/aa374224(v=vs.85).aspx
Assembly Searching Sequence
If an isolated application specifies an assembly dependency, side-by-side first searches for the assembly among theshared assemblies in the WinSxS folder. If the required assembly is not found, side-by-side then searches for a private assembly installed in a folder of the application's directory structure.
Private assemblies may be deployed in the following locations in the application's directory structure:
In the application's folder. Typically, this is the folder containing the application's executable file.
In a subfolder in the application's folder. The subfolder must have the same name as the assembly.
In a language-specific subfolder in the application's folder. The name of the subfolder is a string of DHTML language codes indicating a language-culture or language.
In a subfolder of a language-specific subfolder in the application's folder. The name of the higher subfolder is a string of DHTML language codes indicating a language-culture or language. The deeper subfolder has the same name as the assembly.
The first time side-by-side searches for a private assembly, it determines whether a language-specific subfolder exists in the application's directory structure. If no language-specific subfolder exists, side-by-side searches for the private assembly in
the following locations using the following sequence.
Side-by-side searches the WinSxS folder.
\\<appdir>\<assemblyname>.DLL
\\<appdir>\<assemblyname>.manifest
\\<appdir>\<assemblyname>\<assemblyname>.DLL
\\<appdir>\<assemblyname>\<assemblyname>.manifest
If a language-specific subfolder exists, the application's directory structure may contain the private assembly localized in multiple languages. Side-by-side searches the language-specific subfolders to ensure that the application uses the specified language
or the best available language. Language-specific subfolders are named using a string of DHTML language codes that specify a language-culture or language. If a language-specific subfolder exists, side-by-side searches for the private assembly in the following
locations using following sequence.
Side-by-side searches the WinSxS folder.
\\<appdir>\<language-culture>\<assemblyname>.DLL
\\<appdir>\<language-culture>\<assemblyname>.manifest
\\<appdir>\<language-culture>\<assemblyname>\<assemblyname>.DLL
\\<appdir>\<language-culture>\<assemblyname>\<assemblyname>.manifest
Note that the side-by-side search sequence finds a DLL file with the assembly's name and stops before searching for a manifest file having the assembly's name. The recommended way to handle a private assembly that is a DLL is to put the assembly manifest
in the DLL file as a resource. The resource ID must be equal to 1 and the name of the private assembly may be the same as the name of the DLL. For example, if the name of the DLL is MICROSOFT.WINDOWS.MYSAMPLE.DLL, the value of the name attribute used in the
assemblyIdentity element of the assembly's manifest may also be Microsoft.Windows.mysample. As an alternative, you may put the assembly manifest in a separate file, however, the name of the assembly and its manifest must then be different than
the name of the DLL. For example, Microsoft.Windows.mysampleAsm, Microsoft.Windows.mysampleAsm.manifest, and MICROSOFT.WINDOWS.MYSAMPLE.DLL.
For example, if myapp is installed at the root of drive c: and requires myasm in French-Belgian, side-by-side uses the following sequence to search for the best approximation to a localized instance of myasm.
Side-by-side searches WinSxS for the fr-be version.
c:\myapp\fr-be\myasm.dll
c:\myapp\fr-be\myasm.manifest
c:\myapp\fr-be\myasm\myasm.dll
c:\myapp\fr-be\myasm\myasm.manifest
Side-by-side searches WinSxS for the fr version.
c:\myapp\fr\myasm.dll
c:\myapp\fr\myasm.manifest
c:\myapp\fr\myasm\myasm.dll
c:\myapp\fr\myasm\myasm.manifest
Side-by-side searches WinSxS for the en-us version.
c:\myapp\en-us\myasm.dll
c:\myapp\en-us\myasm.manifest
c:\myapp\en-us\myasm\myasm.dll
c:\myapp\en-us\myasm\myasm.manifest
Side-by-side searches WinSxS for the en version.
c:\myapp\en\myasm.dll
c:\myapp\en\myasm.manifest
c:\myapp\en\myasm\myasm.dll
c:\myapp\en\myasm\myasm.manifest
Side-by-side searches WinSxS for the no language version.
c:\myapp\myasm.dll
c:\myapp\myasm.manifest
c:\myapp\myasm\myasm.dll
c:\myapp\myasm\myasm.manifest
If side-by-side searching reaches a language-neutral version of the assembly, and a
Multilanguage User Interface (MUI) version of Windows is present on the system, side-by-side then attempts to bind to <assemblyname>.mui. Side-by-side does not attempt to bind to <assemblyname>.mui if the search reaches a localized version
of the assembly. The
assembly manifest of a language-neutral assembly will not have a language attribute in its
assemblyIdentity element. If side-by-side reaches a language-neutral assembly, and MUI is installed, side-by-side searches the following locations using the following sequence for <assemblyname>.mui. Side-by-side uses the same search
sequence if the assembly is culture-neutral, except <no language> is not searched.
Side-by-side searches the WinSxS folder for <assemblyname>.mui.
\\<user's language-culture>\<assemblyname>.mui
\\<user's language>\<assemblyname>.mui
\\<system's language-culture>\<assemblyname>.mui
\\<system's language>\<assemblyname>.mui
\\<no language>\<assemblyname>.mui
For example, if side-by-side searching finds the private assembly at c:\myapp\myasm\myasm.manifest, and myasm is a language-neutral assembly. Side-by-side then uses the following sequence to search for myasm.mui. Note that side-by-side will not search for
a language-neutral MUI assembly.
Side-by-side searches WinSxS for the fr-be version of the MUI assembly.
c:\myapp\fr-be\myasm.mui.dll
c:\myapp\fr-be\myasm.mui.manifest
c:\myapp\fr-be\myasm\myasm.mui.dll
c:\myapp\fr-be\myasm\myasm.mui.manifest
Side-by-side searches WinSxS for the fr version of the MUI assembly.
c:\myapp\fr\myasm.mui.dll
c:\myapp\fr\myasm.mui.manifest
c:\myapp\fr\myasm\myasm.mui.dll
c:\myapp\fr\myasm\myasm.mui.manifest
Side-by-side searches WinSxS for the en-us version of the MUI assembly.
c:\myapp\en-us\myasm.mui.dll
c:\myapp\en-us\myasm.mui.manifest
c:\myapp\en-us\myasm\myasm.mui.dll
c:\myapp\en-us\myasm\myasm.mui.manifest
Side-by-side searches WinSxS for the en version of the MUI assembly.
c:\myapp\en\myasm.mui.dll
c:\myapp\en\myasm.mui.manifest
c:\myapp\en\myasm\myasm.mui.dll
c:\myapp\en\myasm\myasm.mui.manifest
社区附加资源
添加New, undocumented, manifest search behaviour in Windows 7
Windows XP and 2003 Server first looked for a DLL then for a manifest file as described above. If the DLL existed, Windows stopped search no matter if the DLL contained manifest or not. Windows 7 seems to have changed this behaviour. CSRSS now looks forthe manifest in the DLL and if the manifest is not there, Windows closes the DLL handle and tries a corresponding *.Manifest file. This behaviour can easily be see using Process Monitor.
Microsoft, please update the above article.
JurekMak
12/22/2012
DONT use private assemblies!
See http://support.microsoft.com/kb/835322 "Applications that bypass globally serviced side-by-side assemblies may be vulnerable to issues that are fixed by a Microsoft software update"!Alfred E. Neumann
8/4/2012
Write-up of how to use private library assemblies
The information on how to deploy Visual Studio runtime libraries asprivate assemblies is distributed across several MSDN articles that are
sometimes not too easy to understand. I have tried to compile the
relevant information in a single blog article. I hope some of you find
it helpful:
http://it-from-inside.blogspot.com/2010/03/deploying-visual-c-runtime-files-as.html
HelgeKlein
3/3/2010
显示: 继承
保护
相关文章推荐
- 深入理解C++的多态性
- 3、面向对象-继承-多态
- 哈夫曼树实现文件压缩与解压缩
- [置顶] 再谈对协变和逆变的理解
- 异常机制学习笔记
- java那些事情
- 关于python csv文件打开错误:_csv.Error: line contains NULL byte
- xcode UIButton创建、监听按钮点击、自定义按钮 、状态 、内边距
- 数据类型,隐式转换以及json,对象,引用类型,预解析 视频教程
- miniblink修复3D变换的两处渲染Bug
- SlidingMenu侧滑菜单
- [置顶] Java中的逆变与协变
- Codeforces 676C Vasya and String 尺取法
- java连接Sql server 2008步骤
- maven之clean、install命令
- C++连接MYSQL数据库
- 内部类与匿名内部类的概念与使用————Java基础知识
- TCP/IP入门(3) --传输层
- Shell 替换+运算符
- iOS Hit-Testing事件响应链