使用c ++ dll进行Visual Studio 2005 VB调试 - 混合语言调试

时间:2022-09-01 20:52:02

I have a vb project which calls functions in a dll. The dll is created in a separate vs project (portaudio), which is written in c.

我有一个vb项目,它调用dll中的函数。 dll是在一个单独的vs项目(portaudio)中创建的,该项目用c编写。

The dll c project compiles clean and builds the required dll, which I am currently dropping in c:\windows\system to vb runtime can see it.

dll c项目编译清理并构建所需的dll,我目前正在c:\ windows \ system中删除到vb运行时可以看到它。

VB Project lives in c:\devprojects\vbtest

VB项目位于c:\ devprojects \ vbtest中

C Project lives in c:\devprojects\portaudio with the project file in c:\devprojects\portaudio\build\msvc. Dll created in Win32\debug under this msvc directory.

C项目位于c:\ devprojects \ portaudio中,项目文件位于c:\ devprojects \ portaudio \ build \ msvc中。在此msvc目录下的Win32 \ debug中创建的DLL。

When I call the dll function, is it possible for the vs debugger to step through the c function in the dll - I have all the code etc, but I don't know if VS2005 supports this kind of mixed language debugging.

当我调用dll函数时,vs调试器是否可以逐步执行dll中的c函数 - 我有所有代码等,但我不知道VS2005是否支持这种混合语言调试。

If this is possible, could you advise how I should set up my Visual Studio to achieve this.

如果这是可能的,你能告诉我应该如何设置我的Visual Studio来实现这一目标。

Many thanks David

非常感谢大卫

3 个解决方案

#1


It is not necessary to have both projects in the same solution, but you should compile both projects with debug symbols enabled.

没有必要在同一个解决方案中同时拥有这两个项目,但是您应该在启用了调试符号的情况下编译这两个项目。

Now in your VB net solution Project/Properties, in the Debug tab make sure that "Enable unmanaged code debugging" is checked.

现在在VB网络解决方案项目/属性中,在“调试”选项卡中确保选中“启用非托管代码调试”。

Also make sure that the dll loaded is in the same place where it was compiled, else it may not found the pdb where the debug symbols are stored.

还要确保加载的dll与编译它的位置相同,否则可能找不到存储调试符号的pdb。

#2


Create a solution with both projects, add the reference in VB project to C project using 'Add Reference..' dialog -> Project and build them all in debug mode.

使用两个项目创建解决方案,使用“添加引用...”对话框 - >项目将VB项目中的引用添加到C项目,并在调试模式下构建它们。

How do you calls C dll from VB?

你如何从VB调用C dll?

#3


If its VB.NET then this is very easy, just set up a solution with both projects under it, set up their dependencies and ensure that on build the debug version of the VB project links to the debug lib/dll produced from your C++ project. Visual Studio does the rest.

如果它的VB.NET那么这很容易,只需在其下设置两个项目的解决方案,设置它们的依赖关系并确保在构建VB项目的调试版本链接到从C ++项目生成的调试lib / dll 。 Visual Studio完成剩下的工作。

I've done this before a couple of times with C# applications calling a C++ dll. I didn't intend to set this up, but tried stepping through whilst debugging assuming I would get the assembly listing and could at least work out somethig of what was going wrong with my code... however it loaded the correct .cpp file and allowed me to continue stepping through that code.

我曾经多次使用C#应用程序调用C ++ DLL来完成此操作。我不打算设置它,但尝试逐步调试,假设我会得到汇编列表,并且至少可以解决我的代码出错的问题...但是它加载了正确的.cpp文件和让我继续踩过那段代码。

#1


It is not necessary to have both projects in the same solution, but you should compile both projects with debug symbols enabled.

没有必要在同一个解决方案中同时拥有这两个项目,但是您应该在启用了调试符号的情况下编译这两个项目。

Now in your VB net solution Project/Properties, in the Debug tab make sure that "Enable unmanaged code debugging" is checked.

现在在VB网络解决方案项目/属性中,在“调试”选项卡中确保选中“启用非托管代码调试”。

Also make sure that the dll loaded is in the same place where it was compiled, else it may not found the pdb where the debug symbols are stored.

还要确保加载的dll与编译它的位置相同,否则可能找不到存储调试符号的pdb。

#2


Create a solution with both projects, add the reference in VB project to C project using 'Add Reference..' dialog -> Project and build them all in debug mode.

使用两个项目创建解决方案,使用“添加引用...”对话框 - >项目将VB项目中的引用添加到C项目,并在调试模式下构建它们。

How do you calls C dll from VB?

你如何从VB调用C dll?

#3


If its VB.NET then this is very easy, just set up a solution with both projects under it, set up their dependencies and ensure that on build the debug version of the VB project links to the debug lib/dll produced from your C++ project. Visual Studio does the rest.

如果它的VB.NET那么这很容易,只需在其下设置两个项目的解决方案,设置它们的依赖关系并确保在构建VB项目的调试版本链接到从C ++项目生成的调试lib / dll 。 Visual Studio完成剩下的工作。

I've done this before a couple of times with C# applications calling a C++ dll. I didn't intend to set this up, but tried stepping through whilst debugging assuming I would get the assembly listing and could at least work out somethig of what was going wrong with my code... however it loaded the correct .cpp file and allowed me to continue stepping through that code.

我曾经多次使用C#应用程序调用C ++ DLL来完成此操作。我不打算设置它,但尝试逐步调试,假设我会得到汇编列表,并且至少可以解决我的代码出错的问题...但是它加载了正确的.cpp文件和让我继续踩过那段代码。