How to debug a program that doesn’t throw any error - visual-studio-2010

I’m having trouble to find a bug in my application.
The problem is random and don’t throw any error. The web site just keeps loading and loading and eventually gets a timeout.
Is a web application using MVC 3 in VS 2010 Pro.
Some time ago, I see a friend to write something in the url, and gets all the trace of the program…
Sadly, I don’t remember what the command was.
Anyone has an idea of what command is it?
Any suggestion on what to use to debug?
Thanks!
Edgar.
UPDATE!
I finally found the command... is trace.axd
But Its behave the same way... sometimes load without problems and show me all the trace info... and sometimes.. it keep loading and loading...
Maybe something related with IIS?

Turn on break on every thrown exception, run your application in debug mode and wait. If it executes too long then pause application and check where you are or wait for exception that is handled somewhere.

Your friend may have had something like the following built into his application, to dynamically set tracing on.
Trace.IsEnabled = Request.QueryString["trace"] != null ? true : false;
This provides info only if the page is fully loaded. It's probably best if you use the VS debugger to step through code.
If all you loops look ok, investigate code that could result in circular references or deadlocks. These can be difficult to spot sometimes, look for functions or constructors that require results from a calling class. So code that needs the result from a function which in turn need results from the first.

Well, this sounds like you have an infinite loop somewhere.
Look at the code that runs when you visit the URL that gives you trouble. See if there is any loops in there (for/while). If yes, see why if they never exit. You can do this by putting a breakpoint inside the loop and examining its behavior over the iterations.

in MVC the bugs you do not see are most of time (especially in Razor and Ajax work) view compile errors. Sometimes syntax bugs on views just does not show that view and do not stop working.
Try that:
put a breakpoint in view.
If program stops in there it means this view is working. Othervise there is a syntax error in this view.
Another way to see some bug information more than in visual studio is use browser tools.
I use google Chrome. Just open developer tools in it. Open network. And do your request. It will list the requests and responses. Click the response and see the information. After style (it is written Verdana etc) read exception details. Sometimes there is more information :)
I am using MVC 3 in Razor from start. So this is a small bug in asp.net mvc.

Related

What to do about "The Components object is deprecated. It will soon be removed." in dev tools Console

For almost every page I open in Firefox, I see this error in the Console of the developer tool bar:
(!) The Components object is deprecated. It will soon be removed.
The source is the html page. It happens with pages I create, but also on many common websites.
I found this documentation on Components object on MDN web docs, but that does not clarify a lot. Note that even that page shows this message(!)
It looks like a warning, but according to the Console filter, it is an error.
My main questions are:
Is this something for me, as a developer of the page reporting this, to solve?
If so, how do I go about that?
I am not aware of any problems as a result of this. For now, that is.
I have seen this for over a year, maybe longer. I mostly ignore this, but every now and then it starts nagging me again. I don't want my code to break suddenly and would like to get rid of this message obscuring other messages.
This is not for the developer of the page to solve.
While biking back home, a possible cause popped up in my mind: could one of the add-ons I use cause this and yes, that appears to be the case.
I restarted with disabled add-ons and the message was gone.
Then I enabled them one at a time and the culprit is
Selenium IDE.
A bug report on this issue was closed with Won't fix, with the message:
This error will resolve itself when we move to a native app later this year.
In a MozillaZine topic of 2012, it is explained how it could have been solved.
The first one is just a warning that the addon is using "Components"
directly, which won't necessarily always be possible when using the
Add-on SDK. (The preferred way to do it is to access the aliases for
Components.classes and Components.interfaces and such that the SDK
provides by requiring the "chrome" module.) It shouldn't be a problem
right now, but might become one in the future.
it happened for me after installing Selenium plugin in my FireFox.

Debugging in RStudio throws error.

I have an R script that doesn't throw what I expect it to. However, it does run all the way through. To fix it, I've tried setting a breakpoint in order to enter debug mode.
But when I do this, I get an error that says:
debugSource('~/mycode/konfio/Projects/Interest Rates/src/getPARS.R', echo=TRUE)
Error in if (length(funBody[[idx]]) != length(originalFunBody[[idx]]) || :
missing value where TRUE/FALSE needed
I've Googled this error, but only found one link which didn't help. If anyone knows how to get my hands on the Debugger, or somewhere else that I can search for the problem I'll be grateful.
Thank you.
RStudio's breakpoints work by rewriting your function to include debug code. The most likely cause of this problem is a bug in RStudio that's causing it to fail to rewrite your function. There are a few possible solutions:
Remove just the statements you want to debug and put them into a separate function. Set the breakpoint on that function and call it from your main script.
Use browser() based-debugging: just add browser() where you would have set a breakpoint (RStudio's debugger works with R debugging features, too).
Use a newer version of RStudio. Debugging R scripts (as opposed to functions) has improved a lot lately, and if you're feeling especially brave you can try a daily build.
If you have time, please post the contents of the file you're having trouble with to RStudio's support forum; we'd like to take a look and see if we can make a fix in an upcoming version.

Getting object reference error in my MVP application

I am receiving random object reference error in different modules of my application.The errors m facing is intermittent. I did debug of my code it looks all correct. Moreover, whenever I run into that error and I try again (immediately after I got error) with same steps with same input conditions that error does not come up. This is something which is happening not only in in development regions but also in production regions. I tried to analyze and I got some leads that there might be problem with temporary ASP. But I don't know how that can cause object reference errors. Sometimes I see Source error information like App_Web_ighjds[some kind of ID I guess]. I don't know where exactly the problem is? As far as my code is concerned It looks all fine. I believe if there was problem with my code then it should be reproducible every time. Does anybody have any idea why such error might be happening? If it is issue with temporary asp.net files then what I should do to avoid such error?? Any help is much appreciated. Thanks.
You're looking for ideas: I would suspect your module initializers or any DI container initialization.
Look for code that runs only on application start.
I would recommend to reset your web server completely before starting new debugging session.
I would also recommend setting Visual Studio debugger to "Break when an exception is thrown", by going to "Exceptions" settings (Ctrl-Alt-E) and checking the "CLR Exception" "Thrown" checkbox.

How To Ignore and error in Visual Studio WebTests

I'm using Visual Studio to record some web tests. I'd like the test to pass (obviously), but it is failing because of something out of our control - so I'd like to surpress that failure.
One of our pages is using an API from a third party like say, let's pick on, facebook. (It's not facebook, but for sake of argument it is). Let's say that we're using the facebook open-graph api to do something or other, and one of their 1px gif files is not found because one of their developers made a typo in the filename. They don't know it's not found, and the API works perfectly with that request erroring out. I want to surpress the error in the web test upon loading mysite.com/index.aspx because it's an inconsequential error.
Thanks!
Just turn off the propety called "Analyze dependant request" for that specific request in your web test.
Not shure for of the property name, I got the french version of 2010.
In English VS 2010 it is "Parse Dependent Requests"
the problem with turning off the "Parse Dependant Requests" is that the page doesn't actually call them either. In a page that has many images you can clearly see that there is a significant difference in the response time of the page when you have dependant requests on or off.

Exception thrown in a referenced .dll how do I debug?

I'm using watermark extenders on textboxes and an exception is being thrown from the AJAX Control Toolkit .dll. It's strange because this just started happening.
I tried debugging from the Ajax solution and Ajax examples (but with my code), but no dice.
Is there a way to step into the Ajax .dll from my solution to see where this is happening?
Couldn't you just get the source for the Ajax Control Toolkit and include it as a project in your solution and then reference it? You'd then be able to step into the code and if you really needed to, you can just put the precompiled one out when you deploy out.
The source code for the AJAX Control Toolkit is available from:
http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488
Just download and start debugging.
You don't need to include the AjaxControlToolkit project. Just open the file you need (in the VS instance where your code that currently breaks is), and set a breakpoint where appropriate.
Maybe a black box approach is more appropriate here. You said that this error just started - what has changed in your environment to start this? You may be headed down a rabbit hole by stepping through the code. Can you deploy to a clean environment and not get the error? Or, does it work in the dev but not the test environment?

Resources