从C#(VS2013)调用C ++函数时隐藏的调试信息 [英] Debug info hidden when calling C++ function from C# (VS2013)

查看:110
本文介绍了从C#(VS2013)调用C ++函数时隐藏的调试信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS2013解决方案,其中包含2个项目:

I have a VS2013 solution which consists of 2 projects:


  • C#项目

  • 和一个C ++(CLR / DLL)项目

我目前正在尝试解决这些问题,但我一直无法做到远。

I am currently trying to solve these problems, but I haven't been able to so far.


  1. 如果我在C ++代码中放置一个断点并运行C#项目,则调试器在以下情况下不会中断/停止从C#中调用C ++代码。

  1. If I put a break point in the C++ code and run the C# project, the debugger doesn't break/halt when the C++ code is called from C#.

我无法在C ++入口函数中调试(即查看值)局部变量:

I can't debug (i.e. see the values) of local variables in the C++ entry function:


  1. 在VS2013中构建解决方案时会收到此警告:

C:\Program Files
(x86)\MSBuild\12.0\bin\ \Microsoft.Common.CurrentVersion.targets(1697,5)


警告MSB3270:正在构建的项目 MSIL的处理器
体系结构与引用
C:\Projects\MyProject\Debug\DSPClassLibrary的处理器
体系结构之间不匹配.dll, x86。

warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "C:\Projects\MyProject\Debug\DSPClassLibrary.dll", "x86".

此不匹配可能会导致运行时失败。请考虑通过Configuration Manager更改项目的目标处理器体系结构,以使您的项目和引用之间的处理器体系结构保持一致,或者依赖具有与项目目标处理器体系结构相匹配的处理器体系结构的引用。

This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

将C#项目目标平台设置为:AnyCPU

The C# project target platform is set to : AnyCPU

将C ++项目目标平台设置为:Win32

The C++ project target platform is set to : Win32

我不确定什么是正确的设置或如何解决此问题。

I am not sure what the right setting is or how I solve this problem.

推荐答案


  1. 您必须在C#项目的项目设置中设置启用本机代码调试。
    比您在本机代码中的断点要多。有时(在VS2010中非常频繁),您必须将C ++ / CLI中的调试器设置更改为混合调试(默认情况下设置为自动调试)。

  1. You have to set "enable native code debugging" In the Project settings of your C# project. Than your breakpoints in native code will be reached. Sometimes (in VS2010 very often) you have to change the debugger settings in your C++/CLI to mixed debugging (it is set to auto by default).

请参阅1

C#默认情况下,项目始终为AnyCPU。它们可以在32位或64位环境中运行。如果使用VS2013创建,则C ++默认为32Bit。您应该将C#构建设置设置为32Bit,以确保所有设置都能在不同的环境下正常工作。对于32位,设置为 x86。

C# Projects are always AnyCPU by default. They can run in 32Bit or 64Bit environment. C++ are 32Bit on default if created with VS2013. You should set your C# build settings to 32Bit to ensure that all will work proper on different enviroments. The setting is "x86" for 32bit.

这篇关于从C#(VS2013)调用C ++函数时隐藏的调试信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆