Debug exe in visual studio 2010 - visual-studio-2010

Is there a way to debug external exe using visual studio 2010 by shift+double click to run the exe. Normally, to run the application in a special mode we have press the shift and double click the exe, but I have a bug that happens right on start up and I guess I need to add a command line argument to get it into that mode. I hope this makes sense.

So basically you want to attach debugger as soon as the process starts. This should help. Source http://blogs.msdn.com/b/greggm/archive/2005/02/21/377663.aspx
Run regedit.exe
Goto HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Image File Execution Options
Create a new key for your exe (example: foo.exe)
Create a new string value under your exe. The name of the string
value is 'Debugger', and the value is 'vsjitdebugger.exe'

If I understand enough of that, you want to debug a program not launched by VS.. In vs pro+ you can select "debug" and then "Attach to process" so you would start your applicaiton and then can attach to it.

Related

What do I do to run Windbg/dbeng.dll commands from within the Visual Studio debugger and the Immediate Window?

I saw in a video talk by Bart de Smet where he was running Windbg commands by typing them into the Immediate Window in Visual Studio when running the project in debug mode inside the Visual Studio debugger.
So, I wanted to try that myself. So here's what I did:
I went to the Project Properties dialog and then selected the Debug tab, then checked the Enable native code debugging in the Enable Debuggers section.
I set a breakpoint on one of the lines and then launched the project with debugging by hitting F5. When the breakpoint was hit, I opened the Immediate Window and typed the .load command to load sos.dll.
But the message I got as a result read:
.load "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll"
error CS1525: Invalid expression term '.'
Is there something else I need to do?
I am using Visual Studio 2015 Community edition.
Run your application without debugging
Choose Debug/attach to process ...
Choose "Windows User Mode Debugger" as transport
Click "Refresh"
Choose your application
Click "Attach"
Open the "Immediate Window", which will labelled be "Debugger Immediate Window"
Enter WinDbg commands

VS Debugging: Attach to a process that hasn't startet

In Visual Studio I can attach the debugger to any process that is currently running.
I have an application that is calling my DLLs and what I need is to debug this process from it's beginning. Is this possible?
Open the project properties (context menu, Properties or Alt+Enter)
Go to the Debug tab
Choose "Start external program"
Save and close
Choose debug mode
Run the application (F5)
If the application expects the DLL in a specific path, it may be necessary to add a post build step to copy the DLL to the expected location.

Visual Studio 2010 - Debug DLL - Debug Command using rundll32 doesn't work

I have a problem debugging a C++ DLL project in Visual Studio 2010. While debuging I want the DLL to be loaded by rundll32.exe automatically. To do so I follow these steps (like here http://msdn.microsoft.com/en-us/library/c91k1xcf.aspx):
In Solution Explorer, I select the project that creates the DLL.
From the View menu, I choose Property Pages.
In the Property Pages dialog box, I open the Configuration Properties folder and select the Debugging category.
In the Command box, I type: "C:\Windows\System32\rundll32.exe"
In the Command Arguments box I type (main is the function to be executed): output.dll, main
In the Working Directory I type: $(SolutionDir)$(Configuration)
Attach -> yes
After following these steps, I try to debug the DLL, but I get this error:
"Unable to attach. Process "C:/Windows/System32\rundll32.exe" is not running on "MY-PC", Refresh the process list before attempting another attach."
Anyone know how to debug a DLL, without manually starting rundll32.exe from command prompt and manually attaching to this process?
You should set:
"Attach -> no"
otherwise the VS is not trying to start new rundll32.exe process.
Setting Attach -> yes tells VS to attach to existing process.

Debugging Namespace Extensions using Visual Studio

What is the best way to debug a namespace extension using Visual Studio? It's not convenient to use regsvr32 to register and unregister the extension and to restart the Explorer for each and every build. Attaching the debugger to the extension would be a nice benefit.
Is there a simple way to debug a namespace extension using Visual Studio?
If you start explorer with something like explorer.exe /separate,::{desktopguid}\::{yourguid} you should get a separate process for that window and it should pick up new registry entries (or existing entries if you just leave them in there, you could then add a GetWindowThreadProcessId(GetShellWindow(),...)!=GetCurrentProcessId() check and not load in the "main" shell process).
There are also some registry values you can set to change the behavior of explorer: DesktopProcess, SeparateProcess and BrowseNewProcess
To close down the shell without killing the process in taskmgr, use this old shutdown trick: Click Start, and then Shut Down. Hold down Ctrl+Alt+Shift and click Cancel

Launching "Visual Studio Just-In-Time Debugger" without prompting

I have set up my system to automatically attach the visual studio debugger when a certain application is launched using these instructions:
http://msdn.microsoft.com/en-us/library/a329t4ed%28printer%29.aspx
The problem is that I get a dialog box each time that requires me to confirm that I do indeed want to attach the debugger. The dialog also prompts me to specify which visual studio debugger I want to attach (I have VS2003, VS2005 and VS2008 installed on the system). I've selected "New instance of Visual Studio 2008" and checked the "Set the currently selected debugger as default."-box but the dialog keeps popping up.
Thanks
Andreas Brinck
There is a registry entry that determines how the debugger is started. Under
HKLM\Software\Microsoft\Windows NT\CurrentVersion\AeDebug
create a DWORD value named "Auto" with a value of 1, so no confirmation window displays

Resources