您的位置:首页 > 其它

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

2009-12-17 20:56 330 查看
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库,如果逼不得已非得动态链接的话,这篇文章就讲这个的。

示例

请看上面下载中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中的文件版本号一致,否则程序还是会启动出错的。

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>


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

相关文章
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: