Debugging a Visual Studio 2010 DLL Project

I am trying to debug my own C / C ++ DLL project from Visual Studio 2010. I am trying to execute the following instructions: http://msdn.microsoft.com/en-us/library/c91k1xcf(v=VS.100).aspx

I want to use the built-in debugger and be able to change the code, view structures, etc., as it would with a regular .exe project. The instructions on the page above describe the Debugging category in the Configuration Properties section, which I cannot see.

http://img707.imageshack.us/img707/4402/lalasz.png

Simply pressing F5 for debugging results in the following error:

Unable to start the program 'C: \ Users ....... Test.dll'

I have used the debugger for regular .exe projects many times and it works fine on this computer. I'm not sure that right now I'm just missing something very obvious.

Change Since I did not do this from the very beginning, I want Visual Studio to load my DLL into the stub process and allow me to debug the source level from there, as OllyDbg does.

My DLL is not the type that contains a bunch of functions that will be exported and called. Instead, it performs the / case switch in DllMain, and on DLL_PROCESS_ATTACH, a new thread. Therefore, I need Visual Studio to load my DLL into the stub executable and allow it to set breakpoints, etc.

0
source share
4 answers

You right-click the solution name in the Solution Explorer window and get the solution properties. Notice that the window says "Solution Test Property Pages."

Right-click the project name (Test in bold) to specify project parameters.

+1
source

You probably have a startup project that creates a DLL.

You have two options: either change the launch project to another project that creates an executable file that uses this DLL, or configure the debug settings for the dll project from the project properties to launch an external application using this DLL (Project Properties / Debug / Command) .

+3
source

Native DLLs cannot run autonomously - they must be run in the context of some program. See This part of the instructions page to which you referred.

"If you start debugging from a project that creates a DLL, you must specify the executable file that you want to use when debugging the DLL."

+3
source

You will also encounter this problem from a managed project. What Visual Studio tells you is that it cannot start the DLL, just as you cannot double-click the DLL from Explorer and start the program.

To debug a DLL, write a small console application that calls functions from your DLL and executes your code. If your DLL has the foo() function, call foo() from main in the console application. Define the console application as the Run project by right-clicking the project name in Solution Explorer and selecting its option.

Then, when you press F5, you will launch a console application that will call the DLL.

0
source

Source: https://habr.com/ru/post/1402921/


All Articles