zoukankan      html  css  js  c++  java
  • 一分钟明确 VS manifest 原理

    什么是vs 程序的manifest文件

    manifest 是VS程序用来标明所依赖的side-by-side组建,如ATL, CRT等的清单。

    为什么要有manifest文件

    一台pc上,用一组建往往会有不止一个版本号(c:/windows/winsxs或系统文件夹下),程序在载入的时候,不知载入哪个,于是manifest文件来指明。

    manifest在哪儿,怎样创建。

    假设用VS开发,能够Set通过porperty->configuration properties->linker->manifest file->Generate manifest To Yes来自己主动创建manifest来指定系统的和CRT的assembly版本号。

    除了这样产生外部的manifest file,还有embedded manifest信息能够被写到所生成的二进制文件内

    Set porperty->configuration properties->manifest tool->embed manifest  To Yes

    对于xp及早前的windows版本号,external manifest会比embed manifest有更高的优先级,但对于windows server及后的版本号,相反。

    为什么我的manifest明明指明

    name="Microsoft.VC80.DebugCRT" version="8.0.50608.0",

    可是用depends.exe工具却发现引用的是8.00.50727.42呢?

    由于在C:/WINDOWS/WinSxS/Policies下,有publisher configuration file也叫policy文件,如8.0.50727.42.policy文件对依赖做了重定向:

    <dependentAssembly>
    <assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" processorArchitecture="ia64" publicKeyToken="1fc8b3b9a1e18e3b"/>
    <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
    </dependentAssembly>

    指明"8.0.41204.256-8.0.50608.0"都被定向到8.0.50727.42。这是assembly提供商如MS对低级版本号bug的修正而提供的解决方法。除此之外,你也能够用application config文件来对本程序做assembly的重定向。如在你bin local目录下 yourbin.extention.config:

    <configuration>
           <windows>
               <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
              <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC80.ATL" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
            <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
              </dependentAssembly>
              <dependentAssembly>
            <assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/></assemblyIdentity>
            <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
              </dependentAssembly>
           </assemblyBinding>
           </windows>
    </configuration>

    怎样决定我程序manifest信息所指定的assembly版本号信息?

    在assembly头文件里,assembly的版本号信息被指明了。如crtassem.h中

    #ifndef _CRT_ASSEMBLY_VERSION
    #define _CRT_ASSEMBLY_VERSION "8.0.50608.0"
    #endif

    能够改动8.0.50608.0为8.0.50727.42以产生你想要的manifest信息。

    若我想将我的程序公布为独立程序集(isolated application),不去依赖目标pc的系统assembly,该怎么办?

    带上全部依赖的assembly和对应的manifest文件(c:/windows/winsxs),注意,manifest信息要直接能够指定到所附带的assembly DLLs,不须要依赖policy的重定向。

  • 相关阅读:
    webpack中的extract-text-webpack-plugin插件使用方法总结
    vue知识总结第一篇vue组件的定义以及父子组件的传值。
    Java在当前时间的基础上增加N时间
    SVN服务器端和客户端的搭建与使用
    字符串后面去0、补0
    安装Oracle数据库并建立可以用的用户
    【品优购代码外笔记】安装并使用Zookeeper
    【十次方基础教程(后台)】influxDB、cAdvisor、cAdvisor的安装与使用(监控微服务内存,自动扩容)
    【十次方基础教程(后台)】使用Rancher管理容器
    【十次方基础教程(后台)】使用Gogs,Jenkins实现持续集成
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4513935.html
Copyright © 2011-2022 走看看