Is there any way that I can understand that my code is running with Ctrl+F5 or F5?
I wrote a GUI for an application for some students but it doesn't work some time when run it with F5...I want too detect F5 and Ctrl+F5 mode to disable GUI when user run it with F5.
CTRL-F5 runs the application without the debugger attached. You can tell if it was started with plain F5 by checking the System.Diagnostics.Debugger.IsAttached.
If the GUI sometimes breaks when run with a debugger attached, it is likely because you use multithreading incorrectly to access UI properties in a thread other than the main UI thread.
You can use the System.Diagnostics.Debugger.IsAttached Property to tell if a debugger is attached or not, i assume that's what you mean.
Hope that helps
Paul
Related
If I close a browser running a web application, it is desirable that the debugging session dies. After all, this equals to closing a windows application. However, if I stop debugging and the browser has more than one tabs (as often is the case), all of them will close - definitely not what I intended. Not using this option means I continuously forget the debugger running and clicking the stop button is just extra work.
Is there an add-on to Visual Studio or any other trick that allows to do only the first: stop debugger when window is closed?
Who thought it would be a good idea to put two options behind a single checkbox? This is a double-edged sword at its sharpest!
It's not exactly what you want. But, it might be a workaround. If you enable JavaScript debugging in Tools->Options->Debugging and then you Debug->Detach All. The browser should stay open and debugging should stop... Now it would mean that the application is still running, which might not be desirable.
It's a great suggestion to make this an option. I'd encourage you to open a suggestion on developer community.
Tools Options:
Detach:
Is there a facility in Visual Studio, when debugging a desktop app, to remember where the mouse was when I hit a break point so that i may use it in Visual Studio while stepping through code, and then snap it back to that spot when I resume execution? This would help in mouseover events and other position-sensitive workflows.
If there's not something built in, would it be possible to do this with a Visual Studio plugin? Or is there a way to install a hook such that the debugger sends my application an event or interrupt that it could use to save that state on break and restore it on resume?
Thank you.
There's nothing built in to the VS debugger to do this. It's more than mouse position, there are likely subtle state changes (like focus and activation) that would be difficult to save and restore reliably.
A quick and dirty thing to do is to add some OutputDebugString messages to the code in question to give you clues as to what's going on internally without actually breaking the execution. VS will show the messages in the Output window.
The only way to come anywhere close to what you're after is to use remote debugging. You can remote debug your code running inside a virtual machine so that you don't actually need a separate physical machine.
I have a plug-in DLL that is launched from a secondary (not GUI) thread in the main application. The DLL must grab keyboard events from the application's main window. I am using SetWindowsHookEx() and it works great.
However, if I hit a breakpoint in Visual Studio while the hook is active, and then press a key, Visual Studio and my application lock up completely. This is a problem because I usually use the F-keys to step through code. If I use the mouse and step forward from Visual Studio's Debug menu, it works fine. But using F10 et al. is such a habit, I usually forget to use the mouse.
Is there anything I can do to get my keyboard shortcuts back? Or a different method to listen to the keyboard?
That's pretty inevitable, the debugger break stops the hook from handling notifications so the keyboard goes dead. Using the remote debugger on another machine is a good way to debug code like this. You'll also want to increase the hook timeout so Windows doesn't destroy the hook while you are debugging, HKEY_CURRENT_USER\Control Panel\Desktop\LowLevelHooksTimeout setting. Assuming you are using WH_KEYBOARD_LL.
Some of my unit tests have long debug trace output, say hundreds of lines recording conversations between a client and a web service, so when I view result details, the GUI of Visual Studio freeze, and the symptom is that right-clicking for context menu results in black rectangle. And the other Windows applications freeze as well. Closing the Test Result Details window won't help, and I have to close VS IDE to unfreeze Windows.
Have you seen such symptom? Can you provide a solution or workaround?
Cheers
Andy
Try killing ctfmon.exe. That application has been responsible for more VS headaches and UI freezes than anything else I've encountered.
Is it possible to attach once in native, then open second VStudio window and attach in managed mode?
You can attach WinDbg as non-invasive, which allows you to attach even if another debugger such as VS is already attached. There's a check-box in the popup for Attach to process.
However, doing so will not allow you to control the application from WinDbg as only one debugger may control the debuggee. You can still view memory, threads, etc. (and you can load SOS/PSSCOR2 to inspect managed data).
You can only do this in .NET 4.0