I am debugging an app that makes use of System.Reactive.dll. I am not sure how it happened but all of a sudden while debugging VS will stop and show a "Source not found" window for basically anything from System.Reactive.dll. For example:
Subject.cs not found
You need to find Subject.cs to view the source code for the current call stack frame.
This happens for Merge, RefCount, TakeUntil, Select, etc.
"Enable Just My Code" is checked in the debug options. I am not trying to step into any of these reactive methods (I am just hitting F10 while debugging).
How can I disable this? It is making debugging the app impossible.
According to your description, If “Enable Just My Code” doesn’t work you can try the following methods:
check Enable source server support under Tools > Options > Debugging > General
Reset all settings under Tools > Import and Export Settings
I am debugging a button in my C# code, and I get a JavaScript runtime error thrown on click from a script that I have never touched at a throwerror() line. My coworker, on the other hand, gets an error that points to the actual line in the C# code that is causing the problem. We can't seem to figure out how to get my copy of Visual Studio to throw the helpful non-JS errors.
When I debug (Clicking 'Start Debugging' with Internet Explorer selected), and I try to debug a asp.net button, I receive an error in ScriptResource.axd, like this:
And is shows me that the error is here:
Now, when my colleague does the same process to debug the same code, this is the error he receives:
We are both using IE to debug in Visual Studio. Both VS instances are 2012. I have not come across this issue and neither has my colleague. Does anyone have any insight to this?
Have you tried comparing Exceptions settings in "DEBUG->Exceptions..." with your coworker
The ScriptResource.axd actually does create runtime generated JavaScript.
Have you tried using the continue button? It might cause the follow up error to appear.
I have a c# Azure project that is just a web api, and wanted to remove some of the non-API default components (welcome page, help, etc). After doing so, when launching the application, I get an error message "Object reference not set to an instance of an object." I've seen this before when doing things in Azure, and somehow got around them each time. My question really is: how can I debug this error on my own? This error description is woefully lacking in detail (there's no call stack or anything, as if the app hasn't yet launched, and the dialog is modal so I can't click on anything within VS)
Extra notes:
it's an ASP .NET project.
it works once I publish to Azure.
after copying the project entirely and rebuilding, it seemed to work. then when mucking with NuGet dependencies, we're back to it not working (i've tried deleting my packages folder and having NuGet recreate - no luck; no idea if related to NuGet at all)
I re-copied the project, so just 'MySolutionFolder' -> 'MySolutionFolder - Copy', reopened with same version of VS, runs fine. This is an amazingly sloppy solution obviously, so looking for something better.
As described in a comment, the issue presumably dealt with access rights to various files, most likely NuGet related but possibly Azure as well, which explains why copying to a new solution directory 'fixed' the issue. I would love to see better error info, such as "Error: Visual Studio couldn't write to 'packages.config'", so I know actually where to fix this sort of issue. As it stands now, it's like a compilation error that says "Syntax error in code. Somewhere. Good luck finding it".
Unfortunately, I never did discover a way to debug issues of this sort in a more general way. I eventually worked around the problem, and then saw it pop up again; following advice someone else tried on another forum, I deleted my packages folder, and had NuGet recreate it, which for whatever reason corrected the issue.
Another time, a solution from this question worked (remove and re-add all roles); sometimes this seemed to require an Azure SDK reinstall and computer restart as well.
EDIT
Finally, the best solution I could find was here: delete SUO files and restart VS.
Hopefully this solution will help someone with a similar problem in the future!
tick Debug > Exceptions > Common Language Runtime Exceptions > System > NullReferenceException and run your app
You can enable Intellitrace and remote debug your azure services:
http://blogs.msdn.com/b/webdev/archive/2013/11/05/remote-debugging-a-window-azure-web-site-with-visual-studio-2013.aspx
I've seen similar symptoms when something goes wrong very early in the asp.net app start-up cycle (before the debugger has attached).
One workaround I have used before:
Make sure you are debugging with a local IIS instance and not IIS Express (right click project properties -> Web -> Servers dropdown -> Local IIS
Hit F5 and get your error dialog. (Just to make sure the IIS process has started). Close the error dialog.
Debug -> Attach to Process -> attach to w3wp.exe (iis process). If it's not there make sure 'show processes from all users/sessions' are both checked.
Force a restart of your app by changing the web.config file.
The restart will now occur with the debugger attached to the process from the very start. If that doesn't give any more useful info, then look at turning off 'Just My Code' debugging exception/breakpoint handling and repeating.
For Visual Studio 2019, click on menu "Debug > Windows > Exception Settings".
Under Common Language Runtime Exceptions, tick on System.NullReferenceException. Debugger will break at the point where this exception is caught.
You can setup a local Azure emulator, this is how I've always debugged my cloud apps.
http://msdn.microsoft.com/en-us/library/windowsazure/hh403990.aspx
And maybe do some reading!
http://msdn.microsoft.com/en-us/library/windowsazure/ff683670.aspx
http://msdn.microsoft.com/en-us/library/windowsazure/hh694035.aspx
Inside global.asax:
protected void Application_Error(object sender, EventArgs e)
{
var error = Server.GetLastError();
string message = error.Message;
string callStack = error.StackTrace();
//Write message and callStack to file
...
}
I don't think debugging will help in this case.
However, unloading/reloading your Azure project by right-clicking on it might fix. I'd tried a LOT of things before discovering this one.
As mentioned here.
I also had the "Object reference not set" issue starting Compute Emulator. I found running VS as administrator resolved this.
Changing project target to 4.6.1. seems to have worked for me.
You can debug through logs. Like you can check through diagnostic logs. Enable them through code. There are some configuration for it. I also faced this type of issue and that was very difficult for me to trace. So i enabled the diagnostic logs and write on logs on my custom check point.
I am trying to debug Windows 8 C# Store application with Local Machine debugger. So, I added some incorrect line to MainPage constructor, after InitializeComponent call. I tried the code that causes DivideByZero or NullReferenceException - with the same results.
So, I execute "Start Debugging", and debugger breaks here:
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
Stack information is not available, it is impossible to detect where is an error (only first-chance exception message in the Output window gives a hint).
I tried to define DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION in the project preprocessor symbols. This time I got the following strange message: "A debugger is attached to YourProgram.exe but not configured to debug this unhandled exception".
Only when specific exception type is checked in the "Exceptions" dialog, and DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION is defined, I managed to break on the line which caused the error.
So, what is the right way to break on the offending line, like is was in traditional desktop applications debugging? If possible, without modifying Exceptions list. And what is exactly the purpose of DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION constant?
It looks like a xaml parsing exception. Have you be able to look at the exception message and see where the error is?
Here is some sample screenshot:
Well when you start Visual Studio you must click on debug and then Options and Settings and then General in Debugging and click on Enable Just My Code.
It can be helpful to enable "Common Language Runtime Exceptions" in "Debug/Windows/Exception Settings" before debugging.
Visual studio will now break on the actual error.
I have a WPF MVVM application. When I start Visual Studio for the first time, and run the app in debug mode, I get an exception as described below. Following a clean build, the application runs fine until re-starting Visual Studio and running again.
'The invocation of the constructor on type 'MyView' that matches the specified binding constraints threw an exception.' Line number '135' and line position '8'.
{"Cannot locate resource 'views/myview.xaml'."}
MyView is a UserControl, exists in the folder it's being searched for in and is contained in the main project.
This is a case of a spurious exception, I don't think it had anything to do with not finding the view. I noticed when I disabled a custom logging mechanism I had set up, the errors went away so likely an exception further up was causing this.