vc++ 应用程序向后兼容性

vc++ application backwards compatibility

我有一个软件是用VS 2019和最新的SDK开发的。 运行 在 Windows 10 OS 上是可以的,但是当尝试在旧 Windows OS(7 或 XP)上 运行 时它不无法正常工作(应用程序无法正确启动(0xc0150002))。从 2008 年到 2019 年,我已经尝试安装必要的 vc++ 可再发行组件,但仍然无法正常工作。我尝试使用具有较旧 Windows OS.

的虚拟机进行测试

对于如何实现这一点有什么建议吗?或者我是否需要在旧版本 Visual Studio 中安装和编译我的程序以使其与旧版本 OS 兼容?

您正在寻求弄清楚发生了什么的方法。

Dependencies and see if you can find a problem there. If that fails then Process Monitor 中打开应用程序将是我的下一步,但要在其中发现问题并不容易。一定要仔细看。

还有一个步骤是尝试在另一个 OS 中调试应用程序。你可以在那里安装 Visual Studio,或者你可以 debug the app remotely

正如上面的评论以及对同一错误的其他问题的回答中已经指出的那样,问题出在依赖关系上。通常解决方案很简单(安装明显缺失的 SDK/runtime)。

但有时 缺少什么 并不明显,尤其是在使用与其他第 N 方遗留组件有依赖关系的遗留第 3 方组件时。

错误描述(来自https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55)说

0xC0150002 STATUS_SXS_CANT_GEN_ACTCTX

Windows was unble to process the application binding information. Refer to the system event log for further information.

这并没有解决问题,但提供了一个有价值的线索:系统​​事件日志。

打开 Windows Event Viewer 应用程序并导航至 Windows Logs > Application -- 在那里您应该会找到一个错误条目(最近的,很有可能),为您提供有关缺失依赖项的详细信息, 或依赖关系。

例如,尝试加载 ControlCAN.DLL(CAN 总线接口 DLL)的应用程序无法启动,因为该 DLL 依赖于系统中不存在的 VS2008 运行时:

Activation context generation failed for "C:\path\to\program\ControlCAN.dll". Dependent Assembly Microsoft.VC90.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found. Please use sxstrace.exe for detailed diagnosis.