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.
Related
I'm checking NetOffice and trying to run a simple example from below:
https://github.com/NetOfficeFw/Samples/tree/master/Excel/02%20NetOffice%20Excel%20COMAddin%20Sample/01%20Simple
how can run this example in visual studio? ideally I think it should be opening a blank Excel which contains addin, but when debugging, it just an error "In order to debug this project , add an executable project to this solution...."
so what executable project I need to add?
thanks,
To debug this example, you must do two steps:
The add-in must be registered in the registry to load it when starting Excel.
This step is done automatically, when you built the add-in (this is part of the NetOffice "magic" with the COMAddin attribute).
You can do the registration of the add-in manually too by using regasm.exe.
Excel must be started so that the add-in is loaded and the debugger can be used.
I prefer to set this up in the project properties. Go in the project properties on the tab Debug, go on Start external program and select the path of the excel.exe on your computer.
You could also start Excel and attach the project debugging to the Excel process.
If you have done the two steps, then start debugging by clicking F5. Now Excel starts. If you set a breakpoint, then it should be reached either at the Excel starting process or when you open a workbook in Excel.
I regularly debug several projects contained in one solution using the same Visual Studio instance. For that, I use the "Debug"->"Start new instance" menu on each project I want to debug:
When using the menu "Debug"->"Stop debugging", all projects debug sessions are stopped.
How can I stop the debug session of one project only?
Bring up the Processes window (normally found under Debug -> Windows -> Processes), right click on the process you wish to stop debugging and slect either "Detach Process" (to stop debugging and leave the process running) or "Terminate Process" (to terminate the process)
(This screenshot is of Visual Studio 2012, however the dialog is very similar in previous versions of Visual Studio)
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.
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.
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