什么是 Windows 命令行 EXE 的“并行配置”,我该如何更正?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3611999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:34:31  来源:igfitidea点击:

What is a Windows command-line EXE's "side-by-side configuration" and how do I correct it?

windowsconfigurationside-by-sidedll

提问by Daryl Spitzer

I have a simple .exe written in C++ (built with Visual Studio 2005) that tests some hardware using a supplied API. It works fine on the Windows 7 machine I built it on, but when I copy it to another (Windows 7) machine and run it (from the command-line) I get:

我有一个用 C++ 编写的简单 .exe(用 Visual Studio 2005 构建),它使用提供的 API 测试一些硬件。它在我构建它的 Windows 7 机器上运行良好,但是当我将它复制到另一台(Windows 7)机器并运行它(从命令行)时,我得到:

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

应用程序无法启动,因为其并行配置不正确。请查看应用程序事件日志或使用命令行 sxstrace.exe 工具获取更多详细信息。

What is "side-by-side configuration"?

什么是“并行配置”?

I ran sxstrace.exe and read the usage info. It appears I would need to instrument my exe to generate a log file for sxstrace.exe to be useful?

我运行了 sxstrace.exe 并阅读了使用信息。看来我需要检测我的 exe 来为 sxstrace.exe 生成一个有用的日志文件?

I imagine the problem is my exe requires DLLs that either don't exist on the other machine, or are the wrong version. How do I find out what DLLs my exe uses, and what versions it links to on my machine (where it works)? Any other advice on copying it to another machine and getting it running? Would more information help?

我想问题是我的 exe 需要另一台机器上不存在的 DLL,或者是错误的版本。我如何找出我的 exe 使用的 DLL,以及它在我的机器上链接到的版本(它在哪里工作)?关于将其复制到另一台机器并使其运行的任何其他建议?更多的信息会有帮助吗?

回答by Daryl Spitzer

mfawzymkh's answerto the "application has failed to start because the side by side configauration is incorrect" question (linked to in the question spirulencelinked to in his answer to this question) appears to apply to this question also. mfawzymkh writes:

mfawzymkh回答到‘应用程序未能启动,因为并排configauration一边是不正确’的问题(在这个问题挂spirulence挂在他的回答这个问题)似乎适用于这个问题也。mfawzymkh 写道:

You can resolve this issue by either one of these 1- Install VC8 Debug CRT 2- Build you app as statically linked

您可以通过以下任一方式解决此问题 1-安装 VC8 调试 CRT 2- 将您的应用程序构建为静态链接

And mfawzymkh's comment on that same answer explains how to build as statically linked:

mfawzymkh 对同一答案的评论解释了如何构建为静态链接:

when you build it in VS, go to projects->settings->C/C++->Code Generation and choose Runtime Lib options to be /MTd instead of /MDd

在 VS 中构建它时,转到项目->设置->C/C++->代码生成并选择运行时库选项为 /MTd 而不是 /MDd

I did that and the side-by-side configuration message is gone. (And after installing something else for the DLL I was using, my EXE works.)

我这样做了,并排配置消息消失了。(在为我使用的 DLL 安装其他东西后,我的 EXE 可以工作了。)

回答by Jeff

For what it's worth, I encountered the same issue. In the Event Viewer I had an error message that read:

对于它的价值,我遇到了同样的问题。在事件查看器中,我收到一条错误消息:

Activation context generation failed for "C:\\MyExe.exe".Error in manifest or policy file "C:\\MyExe.exe.Config" on line 12. Invalid Xml syntax.

“C:\\MyExe.exe”的激活上下文生成失败。清单或策略文件“C:\\MyExe.exe.Config”在第 12 行出错。Xml 语法无效。

Sure enough, I'd changed a connection string and left out the closing quote. Added that back in and it solved the issue.

果然,我更改了一个连接字符串并省略了结束语。把它加回来,它解决了这个问题。

回答by user2831980

"when you build it in VS, go to projects->settings->C/C++->Code Generation and choose Runtime Lib options to be /MTd instead of /MDd" worked for me, although I was interested in the Release version instead of the Debug version.

“当您在 VS 中构建它时,转到项目-> 设置-> C/C++-> 代码生成并选择运行时库选项为 /MTd 而不是 /MDd”对我有用,尽管我对 Release 版本感兴趣调试版本。

Microsofto says: /MT Causes your application to use the multithread, static version of the run-time library. Defines _MT and causes the compiler to place the library name LIBCMT.lib into the .obj file so that the linker will use LIBCMT.lib to resolve external symbols.

Microsofto 说: /MT 使您的应用程序使用运行时库的多线程静态版本。定义 _MT 并使编译器将库名 LIBCMT.lib 放入 .obj 文件中,以便链接器将使用 LIBCMT.lib 来解析外部符号。

/MD Causes your application to use the multithread- and DLL-specific version of the run-time library. Defines _MT and _DLL and causes the compiler to place the library name MSVCRT.lib into the .obj file. Applications compiled with this option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCR100.DLL, which must be available at run time to applications linked with MSVCRT.lib.

/MD 使您的应用程序使用多线程和 DLL 特定版本的运行时库。定义 _MT 和 _DLL 并使编译器将库名 MSVCRT.lib 放入 .obj 文件中。使用此选项编译的应用程序静态链接到 MSVCRT.lib。该库提供了一层代码,允许链接器解析外部引用。实际工作代码包含在 MSVCR100.DLL 中,它必须在运行时对与 MSVCRT.lib 链接的应用程序可用。

回答by spirulence

Are you suffering from the same issue as this guy? Side-by-side assemblies, Windows 7, and Visual Studio 2005

你和这个人有同样的问题吗?并行程序集、Windows 7 和 Visual Studio 2005