本文介绍了当远程计算机上未安装 VS 时,使用 CRT 的 DEBUG 版本远程调试应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我说我可以远程调试远程计算机上的发布构建.我设置我的发布版本很像我的调试版本但我主要必须确保未设置 Debug 标志.我已经处理了一段时间并最终决定尝试弄清楚为什么我必须经历这个.我还应该提到,我的远程调试经验仅限于这个项目,并且 C# 程序使用 C++/CLI(使用/clr 构建).DLL 来调解一些关键的 C++ 库.我不需要调试底层 C++ 库,但我确实需要调试 C++/CLI 代码.(我提到这一点的一个原因是我无法在使用/clr 标志时静态链接库).

First let me say that I can remote debug a release build on the remote computer. I set up my release build much like my debug build but I mostly had to make sure the Debug flag was not set. I've dealt with doing this for a while and finally decided to try and figure out why I had to go through this. I should also mention that my remote debugging experience is limited to this project and the C# program uses a C++/CLI (built with /clr) .DLL to mediate to some critical C++ libs. I don't need to debug the underlying C++ libs but I do need to debug the C++/CLI code. (One reason I mention this is I can't link libs in statically while using the /clr flag).

我最近发现了 Dependency Walker,所以我用它来看看发生了什么.结果是设置了调试标志,链接器在 MSVCR100D.DLL 和 MSVCP100D.DLL 中链接,当未设置标志时,它使用没有D"后缀的文件.现在通常我可能只是将这些 .DLL 的版本复制到远程机器上,但有一个问题.我的 VS2010 开发笔记本电脑是 64 位机器,目标机器是 32 位.这意味着我拥有的那些 DLL 的唯一版本是 64 位.我已经在远程机器上安装了 VS2010 的远程调试(我在 2008 年遇到了同样的问题),但它也不包含这些 .DLL 的调试版本(我不知道为什么,但我假设这是由设计).所以我的问题是:

I recently discovered Dependency Walker so I used it to see what was going on. Turns out with the debug flag set, the linker links in MSVCR100D.DLL and MSVCP100D.DLL, when the flag isn't set it uses the files without the "D" suffix. Now normally I might just copy over my versions of those .DLLs to the remote machine but there's a problem. My dev laptop with VS2010 is a 64 bit machine and the target machine is 32 bit. That means the only versions of those DLLs I own are 64 bit. I have installed the remote debugging for VS2010 (I had this same problem under 2008) on the remote machine but it doesn't include the debug versions of these .DLLs either (I'm not sure why but I'm assuming this is by design). So my questions are:

  1. 作为 VS2010 的注册所有者,是否有这些 .DLL 的 32 位版本的有效来源,我可以将其放在远程机器上?
  2. 有没有更简单的方法可以让我获得调试支持?那我可以更改一些其他设置,只是告诉 VS 不要使用这两个 DLL 的调试版本吗?这里的优点是可以设置 DEBUG 符号,并且任何使用它的条件代码都可以工作.

推荐答案

CRT DLL 的调试版本都可以通过标准的 Visual Studio 安装获得,包括 x86 版本,即使在 64 位机器上也是如此.

The debug versions of the CRT DLLs are all available with the standard Visual Studio installation, including the x86 versions even on 64-bit machines.

默认情况下,它们位于以下路径中:

By default, they're located in the following path:

<Program Files folder>Microsoft Visual Studio 10.0VC
edistDebug_NonRedist

在该文件夹下,您将找到两个额外的文件夹(x64x86),其中包含这些 DLL 的各个平台的调试版本.

Under that folder, you'll find two additional folders (x64 and x86) that contain the debugging versions of these DLLs for the respective platforms.

但要特别注意文件夹的名称(Debug_NonRedist).这表明这些调试 DLL 不可再分发.拥有 VS 许可证的开发人员在另一台机器上测试他/她的代码时使用它们当然是可以的,但它们不应该分发到客户端机器并用于运行您的应用程序.(从您的问题中您似乎知道这一点,但无论如何都值得为未来的 Google 员工指出这一点.)

But pay special attention to the name of the folder (Debug_NonRedist). That indicates that these debug DLLs are not redistributable. It's certainly OK for a developer who owns a license for VS to use them when testing his/her code on another machine, but they should not be distributed to client machines and used to run your application. (Sounds like from your question that you know this, but it's worth pointing out anyway for future Googlers.)

或者,您可以更改 Visual Studio 项目针对特定项目配置链接到的 CRT DLL 版本.这意味着您可以编译应用程序的调试"版本,但告诉 Visual Studio 链接到 CRT 的完整可再发行版本.

Alternatively, you can change which version of the CRT DLLs that a Visual Studio project links to for specific project configurations. That means that you can compile a "Debug" version of your application, but tell Visual Studio to link to the full redistributable versions of the CRT.

这样做:

  1. 在解决方案资源管理器中右键单击您的项目,然后选择属性".

  1. Right-click on your project in the Solution Explorer and select "Properties".

确保在对话框顶部的下拉框中选择了调试"配置.

Ensure that the "Debug" configuration is selected in the drop-down box at the top of the dialog.

展开 TreeView 中的C/C++"项,并选择代码生成".

Expand the "C/C++" item in the TreeView, and select "Code Generation".

将运行时库"选项的设置更改为多线程 DLL (/MD)"或多线程 (/MT)".

Change the setting of the "Runtime Library" option to either "Multi-threaded DLL (/MD)" or "Multi-threaded (/MT)".

请注意,您只是告诉 Visual Studio 不要使用每个选项的调试"变体.他们仍然是同一个意思.第一个将动态链接到 DLL,第二个将 CRT 静态链接到您的应用程序.选择最适合您的情况的一种.(我经常发现将我的调试"构建配置为静态链接这样的实例很方便.)

Notice here that you're just telling Visual Studio not to use the "Debug" variants of each of these options. They still mean the same thing. The first will dynamically link to a DLL, the second will statically link the CRT into your application. Pick the one most appropriate for your case. (I often find it convenient to configure my "Debug" builds to statically link exactly for instances like this.)

这篇关于当远程计算机上未安装 VS 时,使用 CRT 的 DEBUG 版本远程调试应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:23