如何发布VC2005/VC2008编译的程序

Author: 徐艺波  From: xuyibo.org  Updated: 2009-06-29

 

 

mainfest.rar  1.0.0

 

用VC2005/VC2008编译出来的程序,如果拷贝到没有安装相应VC的机器上,很多时候会运行出错:

The application failed to initialize properly (0xc0000135).
This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem.
The system cannot execute the specified program.
,一般最和谐的解决办法是静态链接C运行库、MFC库,如果逼不得已非得动态链接的话,这篇文章就讲这个的。

 

  1. 示例

    请看上面下载中manifest.rar中例子

    首先你需要做的就是修改tst.exe.manfiest为你自己主程序名称,比如你的主程序叫hello.exe,那么就是hello.exe.manifest,其模板见下面一节。

    然后根据需要删除不需要的,一般来说如果你没有链接MFC,那么就删除Microsoft.VC90.MFC所在的dependency,有兴趣的还可以写个小程序来自动生成合适的manifest文件。

    最后就是拷贝需要的Microsoft.VC90.MFC这些目录到发布包中,你可以在X:/Program Files/Microsoft Visual Studio 9.0/VC/redist中找到你需要的这些文件。注意,你要保证xxx.exe.manifest中的version和Microsoft.VC90.MFC中的文件版本号一致,否则程序还是会启动出错的。

  2. xxx.exe.manifest
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    
      <!-- 如果程序需要链接C运行库,请包含这个,一般都是需要的 -->
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    
      <!-- 如果程序需要链接MFC,请包含这个,如果不需要请删除,否则程序启动出错 -->
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.VC90.MFC" version="9.0.30729.1" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    
      <!-- 如果程序运行时需要XP风格的界面,请包含这个 -->
      <dependency>
        <dependentAssembly>
          <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    </assembly>
    
  3. 参考

    How to: Deploy using a Setup and Deployment Project
    Troubleshooting C/C++ Isolated Applications and Side-by-side Assemblies
    Redistributing Visual C++ Files

     

  4. 相关文章
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值