Debugging Visual Studio web application in Release Mode - javascript

I have a Visual Studio 2013 Web Application project that breaks when in Release mode. No console errors are thrown and I think that it must have something to do with script minifying/concatenating. Everything's fine when I build in Debug Mode.
So I'm trying to figure out how to debug when in Release mode and having no luck.
Most articles, like this one, suggest modifying C/C++, Linker and other properties... but I don't have see those options, I assume because I'm working on a web app project.
Are there other ways I can enable debugging, break points, console.logs, etc in Release Mode?

If you're trying to debug a web application then no you're not going to see those options, as they're only available for C++ solutions. To debug a C# or VB web application you need shouldn't need to do any special configuration.
If it's not working however there are some simple things you can check, firstly that the PDB files are generated. These are essentially debug symbols that match the original source code up to the compiled output, allowing visual studio to step through the code and they should be placed in the same directory as your DLLs.
Once you've got your PDB in place all you need to do is attach the debugger. Now for a web application this can be a little confusing at first (if you're using IIS). IIS has several application pools:
The IIS process that you want to attatch to is called w3wp which is a little confusing at first. And potentially there are several of them (one for each AppPool that is active and running). Make sure you've got the Show processes from all users checked to see the processes listed:
To make this whole process easier, if you're running a version of Visual Studio that allows extensions take a look at AttatchTo. It adds a menu option you can click (and convert to a toolbar button/shortcut) that will automatically attach to all the IIS instances to debug your code.

Related

Unable to debug browser JavaScript with Visual Studio 2017 or 2019

I am trying to debug a Web app with some ASP.NET (vbhtml) components and some more regular HTML5 bits. It was built several years ago and makes extensive use of Knockout. Some of these parts are broken and I am trying to debug them.
The project includes an API (WebAPI 2) and some other stuff. It is not straightforward to separate out the HTML5 parts and debug them using VSCode, so I think I am stuck with using Visual Studio.
For a tantalizing few minutes two days ago I was able to set breakpoints, step through the Javascript code and find one problem. I am not sure what I did right. Since then I have been unable to do any debugging of the Javascript components. I have tried using Visual Studio 2017 and 2019.
I ran debugging with Chrome selected and script debugging enabled. As soon as the browser launched, the breakpoint got a yellow flag at its left hand end which showed a message: The breakpoint will not currently be hit. Breakpoint set but not yet bound.
The browser ran normally but the breakpoint was not hit. When the Inspect window was open I could see some stuff heppening but nothing relevant.
I set up a new "Browse With" entry in Visual Studio. I selected chrome.exe and added --remote-debugging-port=9222 in the Arguments field. Saved it and started debugging. After the browser opened, I got pop-up error message: Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:51772).
Every time this happens I get a different port number at the end. When I click OK, debugging stops and the browser window closes. I have made absolutely sure that Chrome is closed before starting debugging, to the extent of running a batch file that kills all Chrome processes.
After more searching I selected the Chrome debugging configuration and then Debug|Start Without Debugging. Chrome started OK. I then selected Attach to Process and selected the process. It all looked good but the breakpoint went inactive again with the "breakpoint will not currently be hit" message.
I have tried adding "debugger;" entries to the code. VS 2019 complains about them and they have no effect.
If I try debugging with IE11 and got similar results. Sometimes I got an error saying that another debugger was already connected although I had previously killed Chrome.
I am at a loss. Any clues would much appreciated.
Rob
The problem was definitely in the bundle configuration. In my case it is a file called BundleConfig.vb. It appears to bundle up JavaScript and css files to enable faster loading of the site rather than loading each of the files as a discrete HTTP request.
My file starts like this:
Imports System.Web.Optimization
Public Module BundleConfig
' For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
Public Sub RegisterBundles(ByVal bundles As BundleCollection)
bundles.Add(New ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-3.4.1.min.js",
"~/Scripts/jquery-ui-1.12.1.js"))
and ends like this:
BundleTable.EnableOptimizations = False 'Commented out 190601 to debug scripts
'BundleTable.EnableOptimizations = True
End Sub
End Module
If EnableOptimization is True you will not be able to debug any of the JavaScript with either Visual Studio or the debug tools in Chrome or IE. Comment it out and debugging becomes possible.

What debugging options are available for Node.js? Esp. in Visual Studio Code

I come from developing in ASP.NET MVC/C# using Visual Studio. In this stack, debugging is very thorough and straightforward. You create a project, code, set breakpoints, and hit F5 to step through them.
What are my options with Node.js? Specifically using Visual Studio Code? I've tried setting up a debug config file but it has mixed results, and seems to be a lot more error-prone than debugging in C#/Visual Studio. Is there any way to get debugging features streamlined in Node the same way I am used to in Visual Studio with C#? I know JS is interpreted rather than compiled...
Update: I have tried clicking the debug button and setting up a launch.json file. However, this usually leads me into errors. For example, I have set up launch.json to my app's entry point and my app uses an MVC pattern. When I launch the app, the debugger stops at the breakpoint before I even visit the controller endpoint, whereas in Visual Studio with C#, the debugger would listen and when I visit the endpoint, it would then stop at the breakpoint so that I could step through. The Visual Studio Code/Node debugger seems to want to step through all breakpoints before the endpoints are even triggered. I have also tried the Nodejs Tools extension for Visual Studio 2015 Community, which produced Microsoft Typescript errors. It just deosn't seem very straightforward.
have you tried using Chrome? When in Chrome press F12 to get the Developers Tools displayed, then you have the output console and can see the source and set break points.
Here are some options for debugging node outside of visual studios:
How do I debug Node.js applications?
Now for backend, I would recommend using Postman for Chrome:
https://www.getpostman.com/
It will consume any API and allow you to see if the information you have entered is correct. A huge time saver if you want to check the routes of an API, the parameters being sent to the API, and data being sent back.
It would seem as most people don't know how to use or know that it can even be used to debug in visual studios.

Rendering in Aptana Different than in a Static Browser

I am experimenting with developing a primitive web interface using Aptana Studio 3, and when I run the site from Aptana as an internal server in either IE or Firefox, the page renders as I expect. In contrast, when I open the same HTML page in a browser (i.e. not running it through Aptana), it displays incorrectly (e.g. modal dialog appears at the bottom of the page rather than as modal when I click a button).
I tried different "meta" compatibility commands at the top of the HTML code to see if I could duplicate how Aptana opens the site. I am not sure if JS and JQuery need to be run as a server or if this is an indication of a bug in my code. If it is a requirement to run JS, JQuery, and bootstrap in a server as Aptana does, any guidance on how to duplicate what Aptana is doing in a standalone offline fashion would be sincerely appreciated.
Note: This is a for a class assignment. The assignment is unrelated to JQuery and Javascript; rather it is on UI design patterns and software engineering. The reason I am using JS and JQuery is I thought this assignment would be a good opportunity to become more familiar with those tools.
For most standard browsers, many jQuery features do not render/appear correctly if they are not run inside a web server. When entering debug or run mode in Aptana, it is in the background starting a local web server. If you want a free web based server, I recommended using the "rawgit" feature bundled with Github; this is what I ended up using. For more information, see here:
https://rawgit.com/

Enabling JavaScript in Visual studio browser opened for Web Performance testing

I am performing web performance testing for a cloud based application with AAD authentication. After recording when I am trying to replay it My visual studio browser is displaying an error that "Java Script is disabled". Is there any way to Edit the Visual Studio's Browsers setting or for Web performance testing is it possible to open the IE instead of Visual Studio browser.
You cannot do that.
Visual Studio web tests do not use a browser. Visual Studio includes a very simple browser that gives an idea of the web pages etc that are retrieved. The web tests are intended to simulate the load that a browser creates, to put load onto the web server. By design Visual Studio web test facilities do not try and run JavaScript or other scripts, nor do they process .css files. They do download all such files requested by the web page.
The activity of code such as JavaScript must be simulated within your test scripts. Look at the request the JavaScript created and that Visual Studio recorded. Sometimes recording the transaction with Fiddler2 can lead to a better understanding of what the JavaScript has done. Work out which pieces of the request are set by the JavaScript and how to derive their values.
Sometimes recording two, as far as possible, indentical web tests and then comparing them as text files will help to reveal what the JavaScript has done. Sometimes comparing the recordings of two identical, but for different users, or for different application-specific items, will help.

The breakpoint will not currently be hit. No symbols have been loaded

I am struggling with breakPoint issue in VS 2012 for more than hours. I am from eclipse background, there I never heard about such issues.
Problem :
The breakpoint will not currently be hit. No symbols have been loaded
for this document.
I have placed the break point in click action of Jquery.
I found the issue using the IE script debugging., The file loaded was old file., i.e I have modified a lot, but I can see no changes in the one which is loaded in IE. How to fix the bug
What I have Tried :
I know this question is duplicate, but being a newbie to VS and C#., I could not understand the older answers. For example, in this answer, he told to choose Debug -> Windows -> Modules. But I doesn't have Modules under windows in VS 2012. Also even though I read, I could not understand the explanation.
Also I am quite new to term Assemblies and PDB. Though, I located PDB files as he said. But how to open the .pdb file?
Need :
Could anyone explain me the same answer in easier term (with more explanation).
I found this out by accident with my VS2012 and ASP.NET MVC, maybe it can help somebody. I noticed that breakpoints in javascript that's inline in the *.cshtml file like this won't get hit (note that this file is a cshtml file):
But breakpoints in external *.js files will get hit:
Try to add debugger; key word before $.getJSON
Also make sure if you use IE to un-check the disable script debugging
Internet Options> Advanced tab> Under Browsing.
As I think this issue is related to Javascript debugging not C#
This results for me:
In your web application make sure Silverlight and ASP.NET debugger are enabled.
How to get there?
=> Right click on the Web Application => Properties => Web tab. Under Debuggers section make sure Silverlight and ASP.NET are enabled.
Running Visual Studio 2013 or Visual Studio 2015 RC, I've found that to get a breakpoint to work in a .js file I need two things to be true:
I need to start Visual Studio by right-clicking the VS shortcut and select "Run as administrator". (If right-clicking on the Taskbar icon, select the application shortcut icon from the pop-up menu and right-click on that to get a context menu that includes "Run as administrator".)
I need to set Internet Explorer as the default browser that will be opened for the web debugging session. If I choose Chrome or Firefox, the breakpoint doesn't work for me.
After opening and closing VS, rebooting the PC with all with no chance, this workaround worked for me in VS 2012 ( Ver 11.0.50727.1 RTMREL ):
In Project Property Pages, under Start Options, in Debugger section, only ASP.NET was enabled. As soon as I enabled Native Code and SQL Server, that red circle with plus sign inside, enabled again.
No idea why this worked! No active connection in Server Explorer nor using any native code in the project!
I had the same problem. You can use VS2017 to debug JS code this way.
When you set VS to launch the browser (Chrome in my case), it opens a new Chrome window. I was trying to debug the specific code (different URL from the window that opened) in a new tab. So I had the 'The breakpoint will not currently be hit. Breakpoint set but not yet bound' in VS.
I found out that if I opened the new URL in the original tab it suddenly worked. Seems that VS is tied to that particular tab.
Hope this helps.
These are the particulars of my situation: VS 2017 - Mainly C# code with some embedded HTML/JS which I needed to debug, Chrome (Version 68.0.3440), Windows 10
As this is Javascript code, so you need to use a javascript debugger. Generally internet browsers come with a debugger/inspector menu, which allows you to inspect/debug your javascript easily. Such debuggers come with a lot of useful features such as HTTP request/response inspection, browser session/local storage, etc.
Actually there is "Modules" option, but it's enabled only when you are in debug mode.
You can just press Ctrl+D,M combination when you're in debug.
In few words, PDB is a file that contains all debug information about your assebmly, you can not debug an assembly without this file. Assembly is a file that contains precompiled code for exetuion via CLR.
Could you provide a bit more information about your problem. What kind of application you are trying to debug for example?
Also, if you have located you pdb files made EXACTLY for your assembly, you can load it by right-clicking your assembly in modules window and selecting Load Symbols From > Symbol Path
Try deleting all breakpoints and restarting debugging in Visual Studio.

Categories