VS2005 开发的程序,用VS2022 打开,遇到了一些问题:
1. 代码打开后发现很多inlude 的头文件下都画了线编译报错如下:
Cannot open source file "afxctl.h"
解决方法: 项目右键-->属性--> Configuration properties --> General --> Platform ToolSet --> 改为 Visual Studio 2022(v143).
2. 报错信息如下:
error MIDL2338 switches are contradictory -no_robust vs. -target
error MIDL 1024 Errors on command line --aborting
解决方法: 去掉 -no_robust
项目右键--》 属性--》 MIDL--》 Command Line --> 查看是否同时存在 target "NT60" 和 no_robust .
如果存在,在"Advanced" 选项中,将“Validate Parameters” --> 改为 “Yes(/robust)”.
3. 编译如果出现以下错误:
VS2022 Error MSB8011 Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions. D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets 2412
说明你的程序要注册dll 或者控件,但是权限不够,这时候就要将VS 以管理员身份打开,在重新编译就可以了。