Visual Studio: Real time method call trace? - c#

This is what I'm looking for: I'd like to be able to get a real time method call listing when I am debugging my program. So for example, say I run my program via the debugger if I press a button or do anything in my program I'd like for it to spit out, say on a visual studio plugin, in real time, all the methods it went through when I pressed this button or did some kind of user action with my program.
I actually once wrote a visual studio plugin that does that by using the visual studio profiler api (I had to write a c++ com server dll that receives this information and pipes it back into my c# plugin). I did this a few years back and I have no idea where I put it. But I'm wondering if Microsoft did something like this in visual studio 2010 or if you know of any third party plugins like this because it is a very handy debugging utility.
Thanks

Check out Visual Studio 2010's Intellitrace feature - it might get you what you need: http://msdn.microsoft.com/en-us/library/dd264915.aspx

You should check IntelliTrace debugging in Visual Studio 2010. It works only with x86 though

It's not free, it's not even cheap, but RedGate's ANTS Performance Profiler can provide that data and more.

I think you could achieve that using AOP, e.g. PostSharp and an implementation of it's OnMethodBoundaryAspect and a MultiCastAttribute to apply your aspect to every method of your program. They even have an example for something quite similar to what you want on their site.

Updated link as of 8/15/2018: IntelliTrace
Note that this feature is in Enterprise edition only
From the linked page:
You can spend less time debugging your application when you use
IntelliTrace to record and trace your code's execution history. You
can find bugs easily because IntelliTrace lets you:
Record specific events
Examine related code, data that appears in the Locals window during debugger events, and function call information
Debug errors that are hard to reproduce or that happen in deployment
You can use IntelliTrace in Visual Studio Enterprise edition (but not
the Professional or Community editions).

My Runtime Flow extension shows method call listing when you press a button or do anything in a program. It works outside Visual Studio debugger.

Related

Emitting events during debugging in Visual Studio

I want to be able to capture intellitrace style calls to a certain method during debugging of my app.
Specifically, each time during debugging when MyLibrary.MyClass.MyMethod is called ideally i'd get a pane of sorts in Visual Studio that would contain the info about the event and the method arguments.
Unfortunately, i need to get it working in Professional edition of Visual Studio (which doesn't have Intellitrace).
I have only tried investigating EnvDTE80 and there doesn't seem anything suitable at the first glance.
What would also work is if i could make some custom code run inside the app's app domain while debugging. I could probably use MS Fakes from Enterprise version, generate a shims assembly, place all of debugging into a ShimsContext and then re-route my calls.

VS2015 unmanaged debugging

The shop where I work is currently using VB6 for development using controls and libraries. Someone once showed me how to use Visual Studio to be able to debug this code by simply creating a console application in C# and then changing a few options. He showed me this in VS2010, but I am now using 2015. When I go into the project properties and go to the Debug tab, the option for "Enable unmanaged debugging" is not there. Did Microsoft remove this option? I have searched the web quite a bit, but have had no luck finding a solution.
Also, for kicks, I also have 2010 installed on my machine. The option is available there, however when I attempt to run and debug I get a LoaderLock failure. After researching it I found that I have to disable the exception in Visual Studio. However, it would appear that my exceptions are locked down and I cannot change them as they are all greyed out. I am an administrator on the machine I am using, but I am unsure of where or what I need to change to enable me to change the exception settings.
Any recommendations on either issue would be greatly appreciated. It's not a show stopper for me, but a HUGE inconvenience.

Visual Studio keeps crashing

Visual studio team system 2008 keeps crashing on me. Sometimes it just freezes, or certain parts of the UI get messed up or a weird popup box saying something about unable to load parameters or saying something else about memory or any other number of things.
it usually happens when I do a "complex" task like go into debug mode or do a search across of whole solution or run a unit tests or something like that.
I rebooted my machine countless time, reinstalled it VS, changed my virtual memory settings, flush my page file on every reboot and anything else i could think of.
It seems like VS runs out memory or something.
I have a powerfully machine with lots of RAM so that's not the issue
any suggestions?
You can always try some standard Visual Studio troubleshooting steps:
Clean the solution
Delete / rename all files in your solution created by VS, i.e. all .ncb, .suo, .user files
Launch Visual Studio with all add-ins disabled: devenv.exe /SafeMode
Reset All Settings: Tools -> Import / Export Settings -> Reset All Settings
Delete HKCU:\Software\Micosoft\VisualStudio\9.0 and then restart Visual Studio
Repair the Visual Studio installation through Add/Remove Programs
You might also check whether there is a hotfix available addressing your issue (e.g. KB960075 sounds like a good candidate for you), or whether you find your problem already reported on the Connect website.
The first step is to uninstall all 3rd party add-ins on Visual Studio. In particular if you have multiple add-ins as they can interfere with each other in unexpected ways and cause crashes. After uninstalling repeat your scenarios and see if this fixes the issue.
If not then it's best to consult the application log and find out why Visual Studio is crashing. The log will contain at least the error code of the crash which can searched on google or reposted here for us to take a look at.
Assuming this occurs with VS up to date with all service packs installed, you might try some of these suggestions. If you haven't tried with service packs, do that first.
What version of Windows are you using? If it is Windows 7, try launching Visual Studio with a compatibility mode and see if that resolves the issue. To do this, make a copy of the normal launch shortcut and go into the Properties dialog and set it to run as Windows Vista.
If this doesn't fix it, then you might also consider:
Checking your PATH environment for any weird settings which might be confusing it, e.g. paths pointing to other SDKs
Any 3rd party VS extensions such as source control, refactoring plugins, wizards etc.
Old versions of .NET or SQL server
Also test if the issue occurs for every kind of project or just certain kinds, e.g. does it happen for all projects? Does it happen in C++, C#, VB.NET projects etc.
You can also attach a debugger to Visual Studio, to see what it's doing. Sometimes a particular .sln will trigger bad behavior or more likely, some third-party add-on.
If you believe that you've gotten VS into a wired state, you can try the following command line switches
devenv.exe /ResetSettings (This will reset the visual studio settings to the defaults)
If that doesn't help, as a last resort, you can try
devenv.exe /ResetUserData

Analyzing a .Net application without VisualStudio

Is there a simple, free way to analyze .Net code (set breakpoint, see stack traces, see running threads) without Visual Studio? Note that I don't need to compile the code, just analyze how it works. I have both source code and binaries but I don't have a Visual Studio license. Unfortunately, the solution file gives several error when I try Visual Studio Express.
EDIT: I may be able to get most of the projects in the solution to load, but I don't see an option for "Debug|Attach to process". Is this not available in Visual Studio Express?
Have you tried SharpDevelop?
If I remember right, MonoDevelop is free, runs on Windows, and supports debugging. I'm not sure if this only works with some languages, but you can give it a go!
Edit: Just checked, and MonoDevelop supports debugging of managed code in its Windows version.
Windbg, allthough its probably too low level for you.
if you want to statically peek at it dont forget reflector http://www.red-gate.com/products/reflector/
the worlds best source browser - and it doesnt even need the source
You're probably missing some required DLLs, causing VS Express to give you an error.
Please post the exact error message(s).
Visual Studio Shell (Integrated Mode) allows you to attach to a process. This edition is basically:
Does not include any support for particular languages, but
Allows extensions to be installed to, for example, add support for a new language
Allows you to attach to a process using the managed or native code debugger

Visual Studio 2008 .Net - Step Over Current Process

I try to debug several applications that communicates with each other - and want to have ability to step over without switching to another process/thread.
So Visual Studio has command "Step Over Current Process (Ctrl-Alt-F10)" - which looks like what I want but it's disabled, why?
I've found the same question but for C++:
"Step over" when debugging multithreaded programs in Visual Studio
So write macros is only way for .net too?
My understanding is there is no real way to do this in visual studio. Unlike Eclipse :D. The best you can do is use the Threads debug window to freeze all threads other than the one you want to debug.
As stated in the comments you can also use a conditional break point and set a filter like "ThreadNameToStopOn" == Thread.CurrentThread.Name

Categories