I'm trying to debug Entity Framework, and I can see the DB calls, but parameter values are not shown. I tried a bunch of options, but was not able to see any of the parameters. Is it possible? If not, it would be a total let down.
As I know IntelliTrace doesn't show parameters for queries. It shows only command text. You need some external profiler to see queries with parameters. You can use SQL Profiler directly or try tools like:
EF Tracing Wrapper
Huagati Query Profiler
EFProf
ORM Profiler
In case of ASP.NET MVC you can also use MVC mini profiler
More about profiling options can be also found in this article.
If you have your IntelliTrace settings configured to collect call information - Tools -> Options -> IntelliTrace -> Events and Call Information then IntelliTrace will collect the values of parameters passed into methods in your code.
If the values that you are interested in are passed as method parameters at some point you should be able to step back through your code to inspect those values. Keep the locals window open and you can see the historical values that IntelliTrace collects as you navigate backward.
Related
On the internet (Microsoft website, e.g.), there's plenty of information on how to create a visualizer.
However, I'd just like to know, which visualizer is currently used by my debugger?
For Native code, that question is very simple:
Menu "Tools", "Options", "Debugging", "Output window", "General Output Settings", "Natvis diagnostic messages", set to "Verbose".
In the Watch-window, enter .natvisreload
Verify the "output" window: all native visualisers are mentioned.
However, now I'm working with managed code, and in my watch-window, I see entries like:
{User Info: 12 User(s), 6 Group(s)
{VDX File Change Info (117 files)}
…
Those entries give me the impression that for this managed code, a/some visualiser(s) is/are used, and I'd like to customise, expand or modify it/them, but therefore I need to know where it/they is/are (sorry for the bad sentence, I just want to emphasize that I have no clue of the whereabouts of the visualiser(s)).
How can I know which managed visualizers are used in my Visual Studio session?
Thanks in advance
Dominique
You'd have to integrate with the debugger and see what types are being evaluated in the watch/autos/locals windows.
From there you can find those types in the list of modules loaded (using debugger apis) and then search for the attributes that Leo mentioned.
There's no debug output anywhere about which type visualizers are loading for managed code. It's actually stored on the types themselves.
How can I know which managed visualizers are used in my Visual Studio session?
According to the document Create custom views of managed objects:
In C# and Visual Basic, you can add expansions for custom data using DebuggerTypeProxyAttribute, DebuggerDisplayAttribute, and DebuggerBrowsableAttribute.
In .NET Framework 2.0 code, Visual Basic does not support the DebuggerBrowsable attribute. This limitation is removed in more recent versions of the .NET Framework.
DebuggerTypeProxy Attribute
DebuggerDisplay Attribute
Hope this helps.
When debug application, it may be usefull to see in what sequence methods are called. It is possible to write Debug.WriteLine("Called MethodName") in earch method but there are big number of methods in my project.
Is there tool that logging method calls?
Runtime Flow (developed by me) shows all function calls in a .NET application.
As mentioned in a comment, the Visual Studio Call Stack window already implements this.
However, if you really wanted more information you can always look in to adding Tracing information.
You could use an AOP (aspect oriented programming) framework to make your life a bit easier.
There is a worked example of how to use PostSharp to log method calls here: http://www.codeproject.com/Articles/337564/Aspect-Oriented-Programming-Using-Csharp-and-PostS
When i use Trace methods (.NET) to see what happening in my code i need to add time to output string in most cases. Thats allow me to see when actually output string was printed. Is there any way to customize IDE (probably, some options or extensions) so time will be added automatically?
There is a set of Visual Studio extensions called Productivity Power Tools available for VS2010 right the way to VS2017. One of the features from 2013 onwards is "Timestamp Margin" which adds a timestamp at the start of each line in the Debug Output Window only. Features in the extension can be enabled individually.
If you're using VS2017, there is also a much more lightweight, standalone extension with just the one feature.
Finally, there is also a much fancier extension called VSColorOutput which colour codes the Debug Output Window based on regular expressions. Optionally it will add timestamps as well.
At the time of writing all of these options work only on the Debug output.
I know this question is tagged with VS2010 but I think anyone reading this still using that version will be in the minority.
Depending on which trace methods you are using, and how picky you are about format, you may not need to write additional code.
You can set the Timestamp or DateTime TraceOption flag on your trace listener's TraceOutputOptions property. You can set that property programmatically or via your configuration file.
The DateTime flag with the default trace listener gives you something that looks like this:
prog1.vshost.exe Information: 0 : Hello world
DateTime=2011-03-12T22:22:55.6902126Z
while Timestamp looks like this:
prog1.vshost.exe Information: 0 : Hello world
Timestamp=991294310087
See the remarks section of the TraceOutputOptions documentation for caveats - e.g., the flags don't affect Write() and WriteLine().
That requires code. In your program. It isn't hard code, works without the debugger too. Which tends to be important if you care about time.
Look at, say, log4net to get this added automatically.
You should be able to write a little function like wchar_t * GetCurrTimestamp() and stick it in your TRACE macro calls, like this:
TRACE(_T("%s: My debug message.\r\n"), GetCurrTimestamp() );
I'm working on a bug where we have a use case that works, and a subtly different use case that doesn't. The code base has next to no logging, and I don't want to spend time now sprinkling logging throught the code base, though I do have time budgeted to do that at a later date.
Is there a tool that logs a program's actions ie, logs each function call?
Apparently Appsight does do this but costs 100,000's.
You could try using our logging tool SmartInspect together with the aspect oriented programming (AOP) framework PostSharp. By using our aspect library, you can automatically instrument and log all method calls, exceptions and even field/property changes.
A solution that doesn't require any code change / recompile would be to use a tool that's based on the .NET Profiling API, which injects its hooks at runtime.
The only free-open-source project i know that traces not just method entry/exit but also the return values/method parameters is SAE (Simple Assembly Explorer). When you open it up, just navigate to your exe, right click on it, and choose Profile.
There are some limits to this tool - specifically, it won't print out the values of generic types, and the text output is not indented/prettified.
Runtime Flow (developed by me) can log each function call with parameters for .NET 2.0 - 4.0 applications without any additional instrumentation.
How to view stack trace of project in debug mode in VS 2008?
I am running and debugging a big application in VS2008. Build mode is DEBUG, Windows Forms project. Is there a way I can see the pieces of codes getting called, something like Stack Trace in exception while i do normal actions in the form like clicking button, etc...
The project is so big I need to easily find the form being called on each nodes on the tree. It would be very helpful if I can see the something like Call Stack Trace. Call Stack is not working like this btw.
Thanks.
Menu: Debug, Windows, Call Stack.
But you say "it is not working", could you elaborate a little?
Sounds like you want some sort of static or dynamic program analysis tool. Here is a good list of some of the more popular tools available for .NET.
Dynamic analysis programs allow you to run the the program and record the class construction and call hierarchy of your application on the fly, for later review.
Static analysis programs require you to point the program at your source code and then build a similar but possibly more exhaustive analysis of your call hierarchy.
See also: What static analysis tools are available for c#